Description
Input
Output
Sample Input
Sample Output
1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 int main() 5 { 6 int x1, x2, x3, x4; 7 int ac[6000], i, n, j, k, a, b, c, d, min; 8 ac[1] = 1; 9 a = b = c = d = 1; 10 for(i = 2; i < 5900; i++) 11 { 12 x1 = ac[a] * 2; 13 x2 = ac[b] * 3; 14 x3 = ac[c] * 5; 15 x4 = ac[d] * 7; 16 min = x1; 17 if(min > x2)min = x2; 18 if(min > x3)min = x3; 19 if(min > x4)min = x4; 20 ac[i] = min; 21 if(min == x1)a++; 22 if(min == x2)b++; 23 if(min == x3)c++; 24 if(min == x4)d++; 25 } 26 while(scanf("%d", &n), n) 27 { 28 if(n%10 == 1 && n%100 != 11) 29 printf("The %dst humble number is %d.\n", n, ac[n]); 30 else if(n%10 == 2 && n%100 != 12) 31 printf("The %dnd humble number is %d.\n", n, ac[n]); 32 else if(n%10 == 3 && n%100 != 13) 33 printf("The %drd humble number is %d.\n", n, ac[n]); 34 else 35 printf("The %dth humble number is %d.\n", n, ac[n]); 36 } 37 return 0; 38 }
原文:http://www.cnblogs.com/yishilin/p/4396068.html