幽幽
 
posts - 51,  comments - 28,  trackbacks - 0

Sum problem
计算1+2+3+...+n

#include<iostream>
using namespace std;
int main()
{
    
int n, temp, sum;
    
for(;cin>>n;){
        sum
=0;
        
for(temp=1; temp<=n; temp++)
            sum
+=temp;
        cout 
<< sum << endl << endl;
    }

    
return(0);
}




 

posted on 2008-02-12 15:36 幽幽 阅读(760) 评论(0)  编辑 收藏 引用 所属分类: HDOJ日志

只有注册用户登录后才能发表评论。
相关文章:
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理



<2024年3月>
252627282912
3456789
10111213141516
17181920212223
24252627282930
31123456

常用链接

留言簿(5)

随笔分类(35)

随笔档案(51)

文章分类(3)

文章档案(3)

相册

我的链接

搜索

  •  

最新评论

阅读排行榜

评论排行榜