水仙花

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

#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);
}

  

 

posted @ 2014-05-31 00:09  木糖醇+杏仁  阅读(176)  评论(0编辑  收藏  举报