AC

大师  •  6天前


include <bits/stdc++.h>

using namespace std;

int main() {

int n;
cin >> n;
//int num[n];
vector<int> num(n);
bool b_swap = false;
for (int &x : num) {
	cin >> x;
}
for (int i = 0; i < n - 1; i++) {
	for (int j = 0; j < n - 1 - i; j++) {
		if (num[j] < num[j + 1]) {
			b_swap = true;
			swap(num[j], num[j + 1]);
		}
	}
	if (b_swap) {
		for (int x : num) {
			cout << x << " ";
		}
		cout << endl;
	}
	b_swap = false;
}
return 0;

}


评论:

请先登录,才能进行评论