N (n <100)

xiaoxiao2021-03-06  67

/ ************************************************** **************** * * Squains from n (n <100) * // * to store the result in array A group of each of the arrays Saving a number, a [0] stores the number of bits of current results * // ****************************************** *************************************** /

#include #include #include #define max 1000 / * is known (N-1)! In array a, seek K! ------- Put (N-1)! Add N-1 time * / void factorial (int * a, int N) {INT * B; INT I, J, R; INT M = a [0]; int carry = 0 ;

B = (int *) malloc (sizeof (int) * (m 1)); if (! b) {printf ("Malloc Memory Error! / N); exit (0);} for (i = 1; i <= m; i ) {b [i] = a [i];

For (j = 1; j

/ * Output result * / void printResult (int * a, int N) {INT i; printf ("% 4d! =", N); for (i = a [0]; i> 0; I -) { Printf ("% d", a [i]);} printf ("/ n");}

INT main () {Int a [max]; int N, k; Printf ("please input the number: / n"); scanf ("% d", & n); a [0] = 1; a [1] = 1; PrintResult (a, 1);

For (k = 2; k <= N; k ) {Factorial (A, K); PrintResult (A, K);} getCh (); return 0;}

转载请注明原文地址:https://www.9cbs.com/read-120038.html

New Post(0)