输出1000以内的水仙花数

//输出1000以内的水仙花数
#include <stdio.h>
#include <math.h>
int main(){
    int a,b,c,s,i;
    printf("水仙花数如下:\n");
    for(i=100;i<=999;i++){
        a=i/100;
        b=(i/10)%10; 
        c=i%10;
        if(i==a*a*a+b*b*b+c*c*c) printf("%d\n",i);
    }
    return 0;
} 

收录于文章《885程序设计考点狂背总目录中

猜你喜欢

转载自www.cnblogs.com/byczyz/p/13385791.html