/* 求小于max的所有水仙花数*/
#include "Stdio.h" #include<math.h> #include<time.h> int arm_number(int max); int main() { int max,second; time_t t; printf("input the max number:"); scanf("%d",&max); second=time(&t); arm_number(max); second=time(&t)-second; printf("The total times is:%d\n",second); return 0;
} int arm_number(int max) { int num,radix=10,x,y,time=0; for(num=100;num<=max;num++) { int n=0,power=1,total=0; while(power<=num) { power=power*radix; n++; time++; } while(power>=10) { x=(num%power)/(power/10); y=n; total+=(int)pow(x,y); power=power/10; time++; } if(total==num) printf("The arm number is:%d\n",num); } printf("The times of computed is:%d\n"); return 0; } 只因水平有限,这个程序看了半天也没有明白每步都什么意思,只好麻烦各位高手了,谁能帮我解释一下各个步骤的意思啊,谢谢了!!