码迷,mamicode.com
首页 > 其他好文 > 详细

水仙花数

时间:2014-06-04 15:52:21      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:c   a   int   for   io      

#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

水仙花数

标签:c   a   int   for   io      

原文地址:http://www.cnblogs.com/sky8-/p/3764771.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!