类似 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 ",i); count++; } } printf("100-999有%d个水仙花数 ",count); }