C语言 100 - 1000 内水仙花数
#include<stdio.h>int main(void)
{
int i,j,k,l,tem,count = 1;
for(i = 101;i <1000;i++)
{
tem = i;
while(tem >= 10)
{
count *= 10;
tem /= 10;
}
j = i/count;//最高位置数字
tem = i % count;
k = tem / (count / 10) ;//次高位置数字
tem = i % (count / 10);
l = tem;
if(i==j*j*j + k*k*k + l*l*l )
{
printf("%-5d",i);
}
}
return 0;
}
运行后 .exe程序停止工作什么原因? 每轮循环count都应该重新赋值为1 BngThea 发表于 2020-3-30 17:24
每轮循环count都应该重新赋值为1
强强强{:5_100:}
页:
[1]