You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.0 KiB

2 years ago
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[5] = {0};
for (int i = 0; i < 5; ++i) {
cin >> a[i];
}
const int len = sizeof a / sizeof a[0];
//--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>----------------
for (int i = 1; i < len; i++) {
int key = a[i];
int j = i - 1;
while (j >= 0 && key < a[j]) {
a[j + 1] = a[j];
j--;
}
a[j + 1] = key;
}
//---------------------------------
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
for (int i = 0; i < len; i++) {
cout << a[i] << " ";
}
cout << endl;
//--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򣨽<EFBFBD><F2A3A8BD><EFBFBD><EFBFBD><EFBFBD>----------------
for (int i = 1; i < len; i++) {
int key = a[i];
int j = i - 1;
while (j >= 0 && key > a[j]) {
a[j + 1] = a[j];
j--;
}
a[j + 1] = key;
}
//---------------------------------
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
for (int i = 0; i < len; i++) {
cout << a[i] << " ";
}
cout << endl;
return 0;
}