题目描述 例4.5 求s=1 +2 +3……+n,当加到第几项时,s的值会超过1000? 输入 无输入。 输出 一个整数n,表示求和到第n项。 #include<bits/stdc++.h> using namespace std; int s,i=1; int main() { while(s<=1000) { s+=i; i++; } cout<<i-1; return 0; }