# Include <stdio. h> # include <windows. h> typedef struct {int num [30]; // store the 21-power int max_index of 0-9; // subscript int max_num marking the highest digit of the 21-power of 0-9; // count the maximum number of digits among the 21 digits in 0-9} biginter; int flag; void init_biginter (biginter * numberflag); void findnumber (int * num, biginter * numberflag, int * sign, int No, int index); int add_biginter (int * num, biginter number, int I); int isletter21 (int * num); int isright (int * num, int * sign); void main () {int I, J; int num [30]; int sign [10] = {0}; // record the number of digits 0-9 in the 21-digit biginter numberflag [10]; int time = gettickcount (); init_biginter (numberflag); flag = 1; printf ("the numbers of daffodils in the 21 bits are \ n"); for (I = numberflag [9]. max_num; I> = 0; I --) {for (j = 0; j <30; j ++) num [J] = 0; sign [9] = I; add_biginter (Num, numberflag [9], I); findnumber (Num, numberflag, sign, 8,21-i);} printf ("program running time: % DMS \ n", gettickcount () -Time);} void findnumber (int * num, biginter * numberflag, int * Sign, int No, int index) {int I, j, temp [30]; If (FLAG) {If (Index = 0 | NO = 0) {If (NO = 0) sign [No] = index; If (isletter21 (Num) {flag = 0; return;} If (isright (Num, sign )) {for (j = 20; j> = 0; j --) printf ("% d", num [J]); printf ("\ n ");}} else {for (I = index; I> = 0; I --) {for (j = 0; j <30; j ++) temp [J] = num [J]; sign [No] = I; If (add_biginter (Num, numberflag [No], I) {for (j = 0; j <30; j ++) num [J] = temp [J]; continue;} findnumber (Num, numberflag, sign, no-1, inde X-I); For (j = 0; j <30; j ++) num [J] = temp [J] ;}}} int isletter21 (int * num) {If (Num [20] = 0) return 1; elsereturn 0;} int isright (int * num, int * sign) {int count [10] = {0 }; int I; for (I = 0; I <21; I ++) Count [num [I] ++; for (I = 0; I <10; I ++) {If (count [I]! = Sign [I]) break;} if (I = 10) return 1; elsereturn 0;} int add_biginter (int * num, biginter number, int I) {int K; if (I! = 0) {k = 0; while (k <= number. max_index) {num [k] + = number. num [k] * I; k ++;} k = 0; while (k <= number. max_index | num [k]/10! = 0) {If (Num [k]/10 = 0) {k ++; continue;} num [k + 1] + = num [k]/10; num [k] % = 10; k ++;} k = 21; while (k <30) {If (Num [k]! = 0) return 1; k ++;} return 0;} void init_biginter (biginter * numberflag) {int I, j, k; int Max; int COUNT = 0; int num [30]; for (I = 0; I <= 9; I ++) {numberflag [I]. num [0] = 1; for (j = 1; j <30; j ++) {numberflag [I]. num [J] = 0 ;}}for (I = 0; I <= 9; I ++) {numberflag [I]. max_index = 0; if (I = 0 | I = 1) {numberflag [I]. num [0] = I; numberflag [I]. max_num = 21;} else {for (j = 1; j <= 21; j ++) {k = 0; while (k <= numberflag [I]. max_index) {numberflag [I]. num [k] * = I; k ++;} k = 0; While (k <= count | numberflag [I]. Num [k]/10! = 0) {If (numberflag [I]. num [k]/10 = 0) {k ++; continue;} numberflag [I]. num [k + 1] + = numberflag [I]. num [k]/10; numberflag [I]. num [k] % = 10; k ++; If (k> numberflag [I]. max_index) numberflag [I]. max_index = K;} // whilecount = numberflag [I]. max_index;} // For} // else} // forfor (I = 2; I <= 9; I ++) {max = numberflag [I]. max_index; Count = max; For (j = 0; j <30; j ++) num [J] = 0; For (j = 1; j <= 21; j ++) {k = 0; while (k <= max) {num [k] + = numberflag [I]. n Um [k]; k ++;} k = 0; while (k <= count | num [k]/10! = 0) {If (Num [k]/10 = 0) {k ++; continue;} num [k + 1] + = num [k]/10; num [k] % = 10; k ++; If (k> MAX) max = K;} COUNT = max; If (max> 20) {break ;} // If} // fornumberflag [I]. max_num = J-1;} //}