hello098 @ 2023-09-09 21:58:43
#include <stdio.h>
int main()
{
int k,n=0;
scanf("%d",&k);
for(int i = 1;i <= k;i ++){
int cnt = 0;
int d = i;
while(cnt < d){
n = n + d;
cnt++;
}
i = i + cnt - 1;
}
printf("%d",n);
return 0;
}
by Soojin2012 @ 2023-09-09 22:17:00
把while(cnt < d)改成while(cnt <= d)试试
by hello098 @ 2023-09-12 11:38:46
@zhengshuyue52 还是不对欸