基础:输入n,计算n+(n+1)+(n+2)+...+(n+100)用do while 怎么做???
#include <stdio.h>int main(int argc, char *argv[])
{
int n,sum,x;
sum=0;
x=0;
printf("请输入n的值:\n");
scanf("%d",&n);
do
{
n++;
sum=sum+n;
x++;
} while(x<100);
printf("结果为:%d\n",sum);
getch();
return 0;
}
//输入0时是对的结果为5050
//输入1时就错了结果为5150(正确答案为5151)
//麻烦看下哪里出错了???