#include<stdio.h>
int main()
{
int a[100] = { 1,3,5,6,10,15,20 };
int key, i, j;
printf("请输入一个数\n");
scanf_s("%d", &key);
for (i = 0; i < 7; i++)
if (a[i] > key)
break;
j = i;
for (i = 6; i >= j; i--)
a[i + 1] = a[i];
a[j] = key;
for (i = 0; i < 8; i++)
printf("%5d\n", a[i]);
}
|
请发表评论