#include <iostream>
2026-10-02 09:26:38
发布于:广东
0阅读
0回复
0点赞
#include <iostream>
#include <algorithm>
using namespace std;
int b[100005];
bool cmp(int x, int y) {
if (x % 10 != y % 10)
return x % 10 > y % 10; // 个位数大的在前
return x < y; // 个位数相同,数字小的在前
}
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> b[i];
sort(b, b + n, cmp);
for (int i = 0; i < n; i++) cout << b[i] << endl;
return 0;
}
这里空空如也








有帮助,赞一个