Daaaaaaazai @ 2021-05-05 18:58:22
循环要怎么用啊???
by Oildum @ 2021-05-05 19:22:23
???你指的是哪种循环?
by lyhqwq @ 2021-05-05 19:29:28
他的意思可能是这道题用循环怎么做(他已经过了一道用循环做的题,所以他大概率知道循环咋用)
by zhanghaiyu @ 2021-07-07 09:38:45
双重循环直接套
by zhanghaiyu @ 2021-07-07 09:41:18
for (int i = 1;i<=10000; i++) {
for (int j = 1; j <= i; j++) {
a = a + i;
b++;
if (b == k) {
cout << a << endl;
break;
}
}
}
return 0;
} 定义和头文件不写了,你自己做的时候加上吧
by 武意程wyc @ 2021-08-16 16:34:09
using namespace std; int main() { int n,i,s=0,a,b; cin>>n; a=1; b=0; for(i=1;i<=n;i++) { s=s+a; b=b+1; if(b == a) { b=0; a=a+1; } } cout<<s; }
一种答案(全AC)
by 武意程wyc @ 2021-08-16 16:34:43
#include<iostream>
using namespace std;
int main()
{
int n,i,s=0,a,b;
cin>>n;
a=1;
b=0;
for(i=1;i<=n;i++)
{
s=s+a;
b=b+1;
if(b == a)
{
b=0;
a=a+1;
}
}
cout<<s;
}