Home > Back-end >  C language program design experiments and exercises the guide (3rd edition) 2-4-7 o combination numb
C language program design experiments and exercises the guide (3rd edition) 2-4-7 o combination numb

Time:10-02

Subject to code program, according to the formula C
? N
? M
??=
? m! (n? M)!
?
? n!
?? Calculated from the n m different elements to retrieve an element (m, n) or less on the number of combinations and

Suggested that the definition and function call fact (n) n! , where n is of type int, function type is double,

Input format:
Input in a row in the given two positive integers m and n (m, n) or less, separated by Spaces,

The output format:
According to the format output "result=combinations of results", the title guarantee results within the scope of the type double,

Input the sample:
2 7



The output sample:
Result=21



Here is my code:
# include & lt; stdio.h>
Int n (int shu) {
Int p=1;
If (shu==0) {
P=1;
} else {
For (int I=1; i<=shu; I++) {
P=p * I;
}
}
return p;
}
Int main () {
Int a, m, p;
The scanf (" % d % d ", & amp; A, & amp; m);
P=n (m)/(n * n (m - a) (a));
Printf (" result=% d ", p);
return 0;
}

CodePudding user response:

Pray god
  • Related