Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
138962 王宇 [在线测评解答教程] 求和 C++ Accepted 1 MS 276 KB 319 2025-11-30 16:11:44

Tests(10/10):


Code:

#include <bits/stdc++.h> using namespace std; int main(){ int n,sum; //循环读入不同的整数n,并求和sum,再输出。 while( cin>>n ){ //sum=1+2+3+......+n sum=0; for(int i=1;i<=n;i++){ sum = sum+i; } cout<<sum<<endl; } return 0; }