li_zhi_a_wei @ 2023-08-12 20:11:00
#include <iostream>
using namespace std;
int main(){
int jinbi=0;
int k;
int i=0;
cin>>k;
while(i<=k){
for(int j=0;j<i;j++){
jinbi+=i;
}
}
cout <<jinbi;
}
by rnf5114 @ 2023-08-12 20:14:00
@MENGw i没有变化
by rnf5114 @ 2023-08-12 20:15:31
#include <iostream>
using namespace std;
int main(){
int jinbi=0,sum=0;
int k;
int i=1;
cin>>k;
while(sum<=k){
for(int j=0;j<i;j++){
jinbi+=i;
sum++;
if(sum>=k){
cout<<jinbi;
return 0;
}
}
i++;
}
cout <<jinbi;
}
@MENGw