求大神指點
#include <stdio.h>
int main()
{
??? //定義三位數num,個位數sd,十位數td,百位數hd
??? int num, sd, td, hd;
??? //循環所有三位數
??? for(num=100,sd=0,td=0,hd=1;num<1000,sd<=9,td<=9,hd<=9;num++,sd++,td++,hd++)
??? {
??????? //獲取三位數字num百位上的數字
??????? hd =hd*hd*hd ;
??????? //獲取三位數字num十位上的數字
??????? td =td*td*td ;
??????? //獲取三位數字num個位上的數字
??????? sd =sd*sd*sd ;
??????? //水仙花數的條件是什么?
??????? if(num==hd*100+td*10+sd )
??????? {
??????????? printf("水仙花數字:%d\n", num);???
??????? }
??? }
??? return 0;???
}
2017-10-04
sd=0,td=0,hd=1,sd++,td++,hd++
就是100,211,322,433。。。