Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- const int N = 110;
- int n;
- int h[N], id[N];
- struct Student {
- int h, id;
- } student[N];
- int main(){
- cin >> n;
- for (int i = 1; i <= n; i ++) {
- cin >> h[i];
- id[i] = i;
- }
- for (int j = 1; j < n; j ++) {
- // (j, n)
- int minIndex = j;
- for (int i = j; i <= n; i ++) {
- if (h[minIndex] > h[i]) {
- minIndex = i;
- }
- }
- swap(h[minIndex], h[j]);
- swap(id[minIndex], id[j]);
- for (int i = 1; i <= n; i ++) {
- cout << id[i] << ' ';
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement