69,371
社区成员
发帖
与我相关
我的任务
分享
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int n,p=0;
int a[100], m = 0;
while (scanf("%d", &n) != EOF)
{
int sum = 1, j = 1, c = 1, i;
while (c < n)
{
for (i = j; i >= 1; i--)
{
sum += 1;
c++;
if (c == n)
break;
}
if (i == 0&&c<n)
{
sum -= 1;
j++;
c++;
}
}
if (c == n)
a[m++] = sum;
}
for (p = 0; p < m; p++)
printf("%d\n", a[p]);
system("pause");
return 0;
}
把 system("pause") 去掉。
把 system("pause") 去掉。