类似 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);} |
原文:http://www.cnblogs.com/u635883/p/3761994.html