//#include "stdafx.h"//
//#include <fstream>//
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
//fstream cin("1001.txt");//
int a;
while(cin>>a)
{
int sum=0;
for(int i=1;i<=a;sum+=i++);
cout<<sum<<endl<<endl;
}
return 0;
}
1001.txt
3
100
该博客展示了如何使用C++编程语言从文件读取整数并计算从1累加到该整数的和,然后输出结果。

被折叠的 条评论
为什么被折叠?



