9. 编程将所有“水仙花数”打印出来,并打印其总个数。 “水仙花数”是一个 各个位立方之和等于该整数的三位数。*/
int a;
int b;
int c;
int sum = 0;
int count = 0;
for(int i = 100; i <= 999; i++){
a = i/100;
b = i/10%10;
c = i%100;
sum = a*a*a+b*b*b+c*c*c;
if(sum==i){
printf("水仙花数是:%d\n",i);
count++;
}else{
continue;
}
}
printf("\t");
printf("总个数count:%d\n",count);
return 0;
}
我写出来的代码,只能打印407,不能打印153,370和371是哪里出错了??? |
|