首页 > 其他 > 详细

水仙花

时间:2014-05-31 14:23:05      阅读:383      评论:0      收藏:0      [点我收藏+]

类似 153=1^3+5^3+3^3  这样的数就叫做水仙花数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <stdio.h>
int main(void){
    int bw,sw,gw;
    int i;
    int count=0;
    for(i=100;i<=999;i++){
        bw=i/100;   //取出百位上的数
        sw=i%100/10;//取出十位上的数
        gw=i%10;    //取出个位上的数
        if(bw*bw*bw+sw*sw*sw+gw*gw*gw==i){
            printf("%d\n",i);
            count++;
        }
    }
     
    printf("100-999有%d个水仙花数\n",count);
}

  

 

水仙花,布布扣,bubuko.com

水仙花

原文:http://www.cnblogs.com/u635883/p/3761994.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!