标题:求助:求小于max的所有水仙花数的解释
取消只看楼主
tangzhongliu
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2005-2-10
 问题点数:0 回复次数:0 
求助:求小于max的所有水仙花数的解释

/* 求小于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; } 只因水平有限,这个程序看了半天也没有明白每步都什么意思,只好麻烦各位高手了,谁能帮我解释一下各个步骤的意思啊,谢谢了!!

搜索更多相关主题的帖子: 水仙花 max 解释 
2005-02-26 23:47



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-12639-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.336842 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved