Files
python/TangDou/LuoGuBook/L12_4.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

37 lines
644 B
C++

#include <bits/stdc++.h>
using namespace std;
struct Node {
char level;
int cnt;
//实现了<运算符重载
bool operator<(const Node &c) const {
return cnt > c.cnt;
}
};
priority_queue<Node> q;
/**
测试用例:
10 13 14 5
*/
int main() {
for (int i = 1; i <= 4; i++) {
Node pic;
cin >> pic.cnt;
pic.level = 'A' + i - 1;
q.push(pic);
}
while (q.size()>2) {
cout << q.top().level << endl;
q.pop();
cout << q.top().level << endl;
q.pop();
cout<<"---------------";
}
return 0;
}