c语言for语句求1+2+...+100,高手看看这段代码哪里错了。

[复制链接]
查看11 | 回复3 | 2012-4-30 20:19:11 | 显示全部楼层 |阅读模式
我粘贴之后,运行结果就是5050啊,没错 下面这个肯定是101啊,sn=a+b,a=1,b最后是100,则sn=101...
回复

使用道具 举报

千问 | 2012-4-30 20:19:11 | 显示全部楼层
#include "stdio.h"void main(){int s=0;int i;for(i=1;i#include main(){...
回复

使用道具 举报

千问 | 2012-4-30 20:19:11 | 显示全部楼层
#includeusing namespace std;int main(){int sum=0;for(int i=1;i#include main(){
int b,sn=0;
for(b=1;b<101;b++)
sn+=b;
printf("%d",sn);
system("pause"); }这样就可以了...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行