1234567891011121314151617181920212223 |
- #include<bits/stdc++.h>
- using namespace std;
- int main() {
- for (unsigned n, x; cin >> n >> x;) {
- if (n == 0 and x == 0)break;
- vector<int> v(n);
- for (auto &e:v) {
- cin >> e;
- }
- v.emplace_back(x);
- for (int i = n - 1; i >= 0; i--) {//插入排序
- if (v[i] <= v[i + 1])
- break;
- swap(v[i], v[i + 1]);
- }
- for (auto &e:v) {
- cout << e << " ";
- }
- cout << endl;
- }
- return 0;
- }
|