#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int a[11] = { 2,5,7,10,17,24,30,38,44,50 };
int n, x, m, y, c;
m = 10; c = 0;
scanf("%d", &x);
for (n = 0; n <= 10; n++)
{
if (x < a[n])
{
for (m = 10; m > n; m–)
{
y = a[m]; a[m] = a[m - 1]; a[m - 1] = y; c = 1;
}
a[n] = x;
break;
}
}
if (c == 0) a[10] = x;
for (n = 0; n <= 10; n++)
{
printf("%d ", a[n]);
}
system(“pause”);
return 0;
}
插入数组元素
最新推荐文章于 2022-08-04 23:05:02 发布