Home > Back-end >  An introduction to a small white consult an array of problems
An introduction to a small white consult an array of problems

Time:10-08


Topics such as above, below is my code, but OJ hint I "Segmentation fault: segment error, check whether there is an array, pointer exception, access to should not have access to the area of memory", consult everybody who is my problem?

#include
using namespace std;
Int comb (int x, int y);
Int fun (int x);


Int main () {
Int t, I;
cout<" Both please enter data group 's number="& lt; Cin> t;
If (t> 0 {
Int * m=new int [t];
Int * n=new int [t];
for(i=0; Icout<" Both please enter m [" & lt; & lt; i<& lt; "] And n [" & lt; & lt; i<& lt; "] (m> N) : "& lt; Cin> [I] m. & gt;> N [I];
}
for(i=0; Icout<[I] comb (m, n) [I] <" \ n "& lt; The delete [] m;
The delete [] n.
}

return(1);
}


Int comb (int x, int y) {
Int z;
Z=fun (x)/(fun fun (y) * (x, y));
Return (z);
}


Int fun (int x) {
If (x!=1) {
Return (fun (x - 1) * (x));
} else {
return(1);
}
}

CodePudding user response:

What is the format of this kind of game, requirements, will be in strict accordance with the format to you, can't do any extra output
You can't cout which input prompt, only honestly
Cin & gt;> t;
For (... ) {
Cin & gt;> [I] m. & gt;> N [I];
}
Cout is only output the final result

In addition, the n! May be beyond the scope of integer, it is necessary to type double calculation;

CodePudding user response:

Fun
reference 2 floor response:
this kind of game, what's required format, will be in strict accordance with the format to you, can't do any extra output
You can't cout which input prompt, only honestly
Cin & gt;> t;
For (... ) {
Cin & gt;> [I] m. & gt;> N [I];
}
Cout is only output the final result

In addition, the n! May be beyond the scope of integer, it is necessary to type double calculation;

OK, I see thank you!
  • Related