输入格式:
每个输入包含 1 个测试用例,即一个不超过 1000 位的正整数 N。
输出格式:
对 N 中每一种不同的个位数字,以
D:M
的格式在一行中输出该位数字D
及其在 N 中出现的次数M
。要求按D
的升序输出。
#include <iostream>
#include <map>
#include <string>
int main()
{
std::map<char, unsigned int> num_count;
std::string str;
std::cin >> str;
for (const char &c : str)
num_count[c] += 1;
for (const auto &c : num_count)
std::cout << c.first<< ":" << c.second<< "\n";
return 0;
}