ac

zhyf  •  2个月前


include <bits/stdc++.h>

using namespace std;

int main() {

int n;
cin >> n;
int a[n];
int k;
for (int i = 0; i < n; i++) {
	cin >> a[i];
}
for (int j = 0; j < n; j++) {
	int t = 0;
	for (int i = 0; i < n - j - 1; i++) {
		if (a[i] < a[i + 1]) {
			k = a[i];
			a[i] = a[i + 1];
			a[i + 1] = k;
			t = 1;
		}

	}
	if (t == 1) {
		for (int i = 0; i < n; i++) {
			cout << a[i] << ' ';
		}
		cout << "\n";
	}

}

return 0;

}


评论:

请先登录,才能进行评论