LZ你某个变量赋初值了吗?
----------------解决方案--------------------------------------------------------
更正:越来越觉得燕子的图片可爱了………………
----------------解决方案--------------------------------------------------------
!!!
[color=white]
----------------解决方案--------------------------------------------------------
----------------解决方案--------------------------------------------------------
....~
----------------解决方案--------------------------------------------------------
1,i没有付初始值,应为int i=1
2,既然要累加,循环变量应为t
我更改后的代码:
#include "stdio.h"
main()
{
int i=0,t;
scanf("%d",&t);
while(t<=100)
{
i+=t;
t++;
}
printf("%d\n",i);
}
----------------解决方案--------------------------------------------------------
#include "stdio.h"
main()
{
int i,t;
scanf("%d",&t);
i=t+1;
while(i<=100)
{
t=t+i;
i=i+1;
}
printf("sum=%d\n",t);
getch();
}
----------------解决方案--------------------------------------------------------