#include<stdio.h>
#define N 100
int main()
{
int a[N] = { 1,3,5,9,666,3333 };
int top = 5; //数组长度标记
int x,i=0,temp,j;
scanf_s("%d", &x);
for ( i; a[i] < x&&i<=top; i++); //找到i的位置
if (i <= top)
{
temp = a[i];
a[i] = x;
for (j = top; j > i; j--)
{
a[j + 1] = a[j];
}
a[i + 1] = temp;
}
else
a[i] = x;
top++;
for (i = 0; i <= top; i++)
printf("%d\t", a[i]);
return 0;
}
练习如有错误,请指正。