为了账号安全,请及时绑定邮箱和手机立即绑定

总是“100以内所有整数之和为:5050”报错

#include <stdio.h>
int main()
{
    int i,sum=0;
    i=0;
    while(i<=100)  //循环条件应该是什么呢?
    {
        sum=sum+i;
        i++;
        printf("%d\n",i);//这里是不是应该改变循环变量的值
    }
    printf("100以内所有整数之和为:%d\n", sum);
    return 0;
}
谁告我错哪了,为虾米验证过不去

正在回答

4 回答


http://physics.scu.edu.cn/search ... D%A5%32%2E%38%6E%68
http://physics.scu.edu.cn/search ... 6%AD%A5%32%2E%38%73
http://www.ie.sjtu.edu.cn/?s=%E5 ... 5%32%2E%38%6B%7A%76
http://physics.scu.edu.cn/search ... 5%32%2E%38%70%62%71
http://www.ie.sjtu.edu.cn/?s=%E6 ... 6%AD%A5%32%2E%38%61
http://physics.scu.edu.cn/search ... D%A5%32%2E%38%65%70
http://www.ie.sjtu.edu.cn/?s=%E9 ... 5%32%2E%38%71%6D%61
http://physics.scu.edu.cn/search ... 5%32%2E%38%6B%72%65
http://www.ie.sjtu.edu.cn/?s=%E6 ... 6%AD%A5%32%2E%38%70
http://physics.scu.edu.cn/search ... 5%32%2E%38%77%6D%6A
http://www.ie.sjtu.edu.cn/?s=%E4 ... 6%AD%A5%32%2E%38%70
http://physics.scu.edu.cn/search ... D%A5%32%2E%38%74%78
http://www.ie.sjtu.edu.cn/?s=%E7 ... 5%32%2E%38%64%62%77
http://physics.scu.edu.cn/search ... 6%AD%A5%32%2E%38%66
http://www.ie.sjtu.edu.cn/?s=%E8 ... 6%AD%A5%32%2E%38%75
http://physics.scu.edu.cn/search ... 6%AD%A5%32%2E%38%7A
http://www.ie.sjtu.edu.cn/?s=%E9 ... D%A5%32%2E%38%72%77
http://physics.scu.edu.cn/search ... 5%32%2E%38%6C%71%76
http://www.ie.sjtu.edu.cn/?s=%E9 ... 5%32%2E%38%65%6F%71
http://physics.scu.edu.cn/search ... D%A5%32%2E%38%69%70
http://www.ie.sjtu.edu.cn/?s=%E5 ... D%A5%32%2E%38%67%70
http://physics.scu.edu.cn/search ... 5%32%2E%38%6D%79%75
http://www.ie.sjtu.edu.cn/?s=%E5 ... 5%32%2E%38%63%61%61
http://physics.scu.edu.cn/search ... D%A5%32%2E%38%64%6A
http://www.ie.sjtu.edu.cn/?s=%E7 ... 5%32%2E%38%7A%64%64
http://www.ie.sjtu.edu.cn/?s=%E6 ... D%A5%32%2E%38%63%6F
http://www.ie.sjtu.edu.cn/?s=%E9 ... 6%AD%A5%32%2E%38%68
http://www.ie.sjtu.edu.cn/?s=%E6 ... 6%AD%A5%32%2E%38%62
http://physics.scu.edu.cn/search ... 5%32%2E%38%78%72%6C
http://www.ie.sjtu.edu.cn/?s=%E6 ... D%A5%32%2E%38%61%69
http://physics.scu.edu.cn/search ... 6%AD%A5%32%2E%38%63
http://www.ie.sjtu.edu.cn/?s=%E6 ... 5%32%2E%38%63%73%73
http://physics.scu.edu.cn/search ... 6%AD%A5%32%2E%38%64
http://www.ie.sjtu.edu.cn/?s=%E8 ... 6%AD%A5%32%2E%38%73
http://physics.scu.edu.cn/search ... 5%32%2E%38%65%6E%69
http://www.ie.sjtu.edu.cn/?s=%E5 ... D%A5%32%2E%38%75%75
http://physics.scu.edu.cn/search ... 6%AD%A5%32%2E%38%65
http://www.ie.sjtu.edu.cn/?s=%E6 ... D%A5%32%2E%38%7A%78
http://physics.scu.edu.cn/search ... 5%32%2E%38%76%77%6F
http://www.ie.sjtu.edu.cn/?s=%E9 ... D%A5%32%2E%38%72%68
http://www.ie.sjtu.edu.cn/?s=%E9 ... 5%32%2E%38%69%6F%6A
http://physics.scu.edu.cn/search ... D%A5%32%2E%38%6A%72
http://www.ie.sjtu.edu.cn/?s=%E5 ... 5%32%2E%38%71%72%62
http://physics.scu.edu.cn/search ... 6%AD%A5%32%2E%38%73
http://www.ie.sjtu.edu.cn/?s=%E4 ... 6%AD%A5%32%2E%38%61
http://physics.scu.edu.cn/search ... 6%AD%A5%32%2E%38%6A
http://physics.scu.edu.cn/search ... 6%AD%A5%32%2E%38%6F
http://physics.scu.edu.cn/search ... 6%AD%A5%32%2E%38%6D
http://physics.scu.edu.cn/search ... 5%32%2E%38%76%66%6C
http://www.ie.sjtu.edu.cn/?s=%E7 ... 6%AD%A5%32%2E%38%70
http://www.ie.sjtu.edu.cn/?s=%E9 ... D%A5%32%2E%38%74%72
http://physics.scu.edu.cn/search ... 5%32%2E%38%69%76%6F
http://www.ie.sjtu.edu.cn/?s=%E5 ... D%A5%32%2E%38%70%6F
http://physics.scu.edu.cn/search ... 6%AD%A5%32%2E%38%70
http://www.ie.sjtu.edu.cn/?s=%E6 ... 5%32%2E%38%6F%70%6F
http://physics.scu.edu.cn/search ... 5%32%2E%38%6B%68%67
http://www.ie.sjtu.edu.cn/?s=%E7 ... D%A5%32%2E%38%75%63
http://physics.scu.edu.cn/search ... 5%32%2E%38%6B%64%6B
http://www.ie.sjtu.edu.cn/?s=%E9 ... D%A5%32%2E%38%75%69
http://www.ie.sjtu.edu.cn/?s=%E8 ... 5%32%2E%38%64%69%7A
http://www.ie.sjtu.edu.cn/?s=%E6 ... 6%AD%A5%32%2E%38%6F
http://physics.scu.edu.cn/search ... 5%32%2E%38%69%6A%78
http://www.ie.sjtu.edu.cn/?s=%E5 ... 5%32%2E%38%66%61%66
http://physics.scu.edu.cn/search ... D%A5%32%2E%38%61%7A
http://www.ie.sjtu.edu.cn/?s=%E5 ... 6%AD%A5%32%2E%38%6A
http://physics.scu.edu.cn/search ... 6%AD%A5%32%2E%38%6D
http://www.ie.sjtu.edu.cn/?s=%E5 ... D%A5%32%2E%38%7A%70
http://physics.scu.edu.cn/search ... 6%AD%A5%32%2E%38%71
http://www.ie.sjtu.edu.cn/?s=%E4 ... 5%32%2E%38%70%76%64
http://physics.scu.edu.cn/search ... 5%32%2E%38%6D%6E%68
http://www.ie.sjtu.edu.cn/?s=%E5 ... 6%AD%A5%32%2E%38%76
http://physics.scu.edu.cn/search ... 6%AD%A5%32%2E%38%6B
http://physics.scu.edu.cn/search ... 6%AD%A5%32%2E%38%6B
http://www.ie.sjtu.edu.cn/?s=%E5 ... 6%AD%A5%32%2E%38%66
http://www.ie.sjtu.edu.cn/?s=%E6 ... 6%AD%A5%32%2E%38%6D
http://physics.scu.edu.cn/search ... 6%AD%A5%32%2E%38%79
http://www.ie.sjtu.edu.cn/?s=%E6 ... 5%32%2E%38%79%66%76
http://physics.scu.edu.cn/search ... D%A5%32%2E%38%75%79
http://www.ie.sjtu.edu.cn/?s=%E6 ... 6%AD%A5%32%2E%38%68
http://physics.scu.edu.cn/search ... 6%AD%A5%32%2E%38%77
http://www.ie.sjtu.edu.cn/?s=%E4 ... 5%32%2E%38%72%67%6B
http://physics.scu.edu.cn/search ... 5%32%2E%38%6D%67%74
http://www.ie.sjtu.edu.cn/?s=%E6 ... 6%AD%A5%32%2E%38%70
http://physics.scu.edu.cn/search ... 6%AD%A5%32%2E%38%61
http://www.ie.sjtu.edu.cn/?s=%E5 ... D%A5%32%2E%38%78%75
http://physics.scu.edu.cn/search ... 5%32%2E%38%6E%75%64
http://www.ie.sjtu.edu.cn/?s=%E5 ... 6%AD%A5%32%2E%38%6D
http://physics.scu.edu.cn/search ... 5%32%2E%38%78%61%76
http://www.ie.sjtu.edu.cn/?s=%E7 ... 5%32%2E%38%62%73%79
http://physics.scu.edu.cn/search ... 6%AD%A5%32%2E%38%76

0 回复 有任何疑惑可以回复我~

++i试试

0 回复 有任何疑惑可以回复我~

楼上说的正是问题所在。

这个教程的结果验证机制大概是只检测最后输出的那一句话。

因为你前面输出了循环变量的值,它就认为你的输出结果不符合要求,所以报错!

0 回复 有任何疑惑可以回复我~

 printf("%d\n",i);//这里是不是应该改变循环变量的值  ,把这句话去掉,人家没让你打印每次变量的值。

1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

总是“100以内所有整数之和为:5050”报错

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信