问答详情
源自:4-9 循环结构之for循环(二)

“运行正确,输入错误”是什么鬼????

int num, sd, td, hd;    //循环所有三位数    
for( num=100 ; num<1000 ; num++ )    
{         
    hd =  num/100;                
    td =  num/10 - hd*10;              
    sd =  num-hd*100-td*10;              
    if(sd*sd*sd + td*td*td + hd*hd*hd == num)         
    {            
         printf("水仙花数字:%d\n", num);            
     }    
}

哪里出错了T_T

提问者:Mr榕 2021-10-31 11:54

个回答

  • weixin_慕沐5236896
    2021-11-11 15:03:26

    if(hd*hd*hd + td*td*td + sd*sd*sd == num)

    hd是百位,sd是个位,写反了