为什么程序不能运行

wangdong20 2011-02-04 02:56:48
#include <stdio.h>

void main()
{
long sum=0l;
int count=0;
int i=0;

printf("\nEnter the number of integer you want to sum:");
scanf("%d",&count);

for(i=count;i>0;sum+=count--);

printf("\nTotal of the first %d number is %ld\n",count,sum);
}
输入数据后,既不显示错误,也不显示最终结果,把count改成i就可以,这是为什么呢
...全文
59 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangdong20 2011-02-04
  • 打赏
  • 举报
回复
太感谢一楼的啦
ww884203 2011-02-04
  • 打赏
  • 举报
回复
楼上说得很清楚了,好好看看for循环吧
smartlean 2011-02-04
  • 打赏
  • 举报
回复
for(i=count;

这儿i只被赋值一次,之后不会赋值的。所以就一直大于0.

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧