题解
2024-03-03 19:45:21
发布于:广东
4阅读
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;
}
这里空空如也
有帮助,赞一个