美文网首页
PAT 1021 个位数统计 (15 分)

PAT 1021 个位数统计 (15 分)

作者: 昭明ZMing | 来源:发表于2018-12-14 14:41 被阅读0次
#include<iostream>
#include<map>
using namespace std;
int main() {
    map<int, int> m;
    char ch;
    while (ch = getchar()) {        
        if (ch == '\n')break;
        m[ch -'0']++;
    }
    for (auto it = m.begin(); it != m.end(); it++)
        cout << it->first << ":" << it->second << endl;
    return 0;
}

GitHub

相关文章

网友评论

      本文标题:PAT 1021 个位数统计 (15 分)

      本文链接:https://www.haomeiwen.com/subject/oblghqtx.html