#include <iostream> using namespace std; int main() { long n = 0; long sum = 0; cin >> n; //循环相加 for (int i = 1; i <= n; i++) { sum += i; } //打印结果 cout << sum; system("pause"); return 0; }
#include <iostream> using namespace std; int main() { long n = 0; long sum = 0; cin >> n; //循环相加 for (int i = 1; i <= n; i++) { sum += i; } //打印结果 cout << sum; system("pause"); return 0; }