文章

14

粉丝

0

获赞

50

访问

9.4k

头像
字母排序 题解:排序万能法:sort函数
P2019
发布于2025年8月17日 19:38
阅读数 923

#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <list>
#include <string>
#include <cmath>
#include <stack>
#include <map>
#include <sstream>
#include <queue>

using namespace std;

map<char, int>counts;

bool com(char a, char b) {
    if (counts[a] == counts[b]) {
        return a < b;
    }
    return counts[a] > counts[b];
}
int main() {
    
    string s;
    while (cin >> s) {
        counts.clear();
        for (int i = 0; i < s.size(); i++) {
            if (counts.find(s[i]) == counts.end()) {
                counts[s[i]] ...

登录查看完整内容


登录后发布评论

4 条评论
eikind
2026年1月31日 21:31

只能用c语言哥

赞(0)

singularity340 : 回复 eikind: 为啥?

2026年2月8日 15:28

eikind : 回复 singularity340: 西南交大只能用c语言写题,这个题目来源不是西南交通的吗

2026年2月21日 15:43

singularity340 : 回复 eikind: 好像是云南大学的吧

2026年2月22日 15:06
回复给: