if语句括号内直接用=号,为什么答案就为水仙花数字:1 水仙花数字:8 水仙花数字:729 水仙花数字:370 水仙花数字:371 水仙花数字:378 水仙花数字:1099
#include <stdio.h>
int main()
{
//定义三位数num,个位数sd,十位数td,百位数hd
int num, sd, td, hd;
//循环所有三位数
for( num=100;num<1000;num++)
{
//获取三位数字num百位上的数字
hd = num/100; ;
//获取三位数字num十位上的数字
td = num%100/10 ; ;
//获取三位数字num个位上的数字
sd = num%10%10; ;
//水仙花数的条件是什么?
if( num=sd*sd*sd+td*td*td+hd*hd*hd)
{
printf("水仙花数字:%d\n", num);
}
}
return 0;
}