可以用一层循环的
程序代码:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int a[10] = {1, 3, 5, 7, 9, 11, 13, 15, 17};
int i, n = 10;
for (i = 9;i > 0;--i)
{
if (a[i-1] < n) break;
a[i] = a[i-1];
}
a[i] = n;
for (i = 0;i < 10;printf("%d\n", a[i++]));
return 0;
}