标签:
//---------------------水仙花数----------------------
int i,j,k;
for (i=1; i<=9; i++){
for (j=0; j<=9; j++){
for (k=0; k<=9; k++){
if ((i*i*i+j*j*j+k*k*k)!=(i*100+j*10+k)){
continue;
}
printf("%d\n",i*100+j*10+k);
}
}
}
//方法2:打印三位数的水仙花数
int i,a,b,c;
for (i=100; i<1000; i++) {
a=i%10;
b=i/10%10;
c=i/100%10;
if (a*a*a+b*b*b+c*c*c==i) {
printf("%d ",i);
}
}
标签:
原文地址:http://blog.csdn.net/ytuzhangziyao/article/details/42234337