gpt4 book ai didi

c - c中的while循环无限期地进行

转载 作者:太空宇宙 更新时间:2023-11-04 02:29:42 25 4
gpt4 key购买 nike

<分区>

当我编译并运行这段代码时,while 循环并没有停止。我哪里做错了?

/*Program to find all armstrong numbers between 1 and 500*/
#include <stdio.h>
int main()
{
int i,rem_t,rem_h,dig_u,dig_t,dig_h;
i=1;
while(i<=500)
{
rem_t=i%100;
rem_h=i%1000;
dig_u=i%10;
dig_t=(rem_t-dig_u)/10;
dig_h=(rem_h-rem_t)/100;
if (i=(dig_u*dig_u*dig_u)+(dig_t*dig_t*dig_t)+(dig_h*dig_h*dig_h))
{
printf("%d\n",i);
}
}
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com