//更简解法
#include<stdio.h>
int main()
{
int a, b, c, n;
scanf("%d", &n);
int arr[51] = { 0 };
for (int a = 0; a < n; a++)
{
scanf("%d", &arr[a]);
}
scanf("%d", &c);
//for (b=n-1; n = 0; n--)//这个循环会直接跳出去为什么
for(b=n-1;b>=0;b--)
{
if (arr[b] <= c)
{
arr[b+1] = c; break;
}
if (arr[b] > c)
{
arr[b + 1] = arr[b];
arr[b]=c;
}
}
for (int i = 0; n > i-1; i++)
printf("%d ", arr[i]);
return 0;
}
int main()
{
int a, b, c, n;
scanf("%d", &n);
int arr[51] = { 0 };
for (int a = 0; a < n; a++)
{
scanf("%d", &arr[a]);
}
scanf("%d", &c);
//for (b=n-1; n = 0; n--)//这个循环会直接跳出去为什么
for(b=n-1;b>=0;b--)
{
if (arr[b] <= c)
{
arr[b+1] = c; break;
}
if (arr[b] > c)
{
arr[b + 1] = arr[b];
arr[b]=c;
}
}
for (int i = 0; n > i-1; i++)
printf("%d ", arr[i]);
return 0;
}