//已有一个已排好序的数组, 今输入一个数, 要求按原来排序的规律将它插入数组中.
#include<stdio.h>
int main(void)
{
int b[11], a[10] = {1, 2, 3, 4, 5, 7, 8, 9, 10, 11};
int i, c;
printf ("Insert c: " );
scanf("%d",&c);
for (i=0; i<10; i++)
{
if(a[i] <= c)
b[i] = a[i];
if(a[i-1] < c && a[i] > c)
{
b[i] = c;
}
b[i+1] = a[i];
}
for (i=0; i<= 10; i++)
printf("%-3d",b[i]);
getch();
}
得不到正确的结果.