题解
2023-07-08 15:02:28
发布于:上海
19阅读
0回复
0点赞
#include <iostream>
using namespace std;
int main() {
int n, x;
cin >> n;
int a[n+1];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
cin >> x;
int i = n-1;
while (i >= 0 && a[i] > x) {
a[i+1] = a[i];
i--;
}
a[i+1] = x;
for (int i = 0; i <= n; i++) {
cout << a[i] << " ";
}
return 0;
}
这里空空如也
有帮助,赞一个