PAT 1021 个位数统计 (15 分)

2018-12-14  本文已影响0人  昭明ZMing
#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

上一篇 下一篇

猜你喜欢

热点阅读