#include <cctype>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
int main(int argc, char** argv)
{
std::vector<int> nums;
nums.push_back(5789);
nums.push_back(-9876);
nums.push_back(12345);
nums.push_back(56789);
nums.push_back(56788);
nums.push_back(-1111);
std::map<char, int> digit_frequency;
for(int i = 0; i < nums.size(); ++i)
{
std::stringstream ss;
ss << nums[i];
std::string str = ss.str();
if(isdigit(str[0]))
{
++digit_frequency[str[0]];
}
else if(isdigit(str[1]))
{
++digit_frequency[str[1]];
}
}
std::map<char, int>::iterator it;
for(it = digit_frequency.begin(); it != digit_frequency.end(); ++it)
{
std::cout << "Number " << it->first << " occurred " << it->second << " time(s).\n";
}
return 0;
}
I2luY2x1ZGUgPGNjdHlwZT4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWFwPgojaW5jbHVkZSA8c3N0cmVhbT4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPHZlY3Rvcj4KCmludCBtYWluKGludCBhcmdjLCBjaGFyKiogYXJndikKewogICAgc3RkOjp2ZWN0b3I8aW50PiBudW1zOwogICAgbnVtcy5wdXNoX2JhY2soNTc4OSk7CiAgICBudW1zLnB1c2hfYmFjaygtOTg3Nik7CiAgICBudW1zLnB1c2hfYmFjaygxMjM0NSk7CiAgICBudW1zLnB1c2hfYmFjayg1Njc4OSk7CiAgICBudW1zLnB1c2hfYmFjayg1Njc4OCk7CiAgICBudW1zLnB1c2hfYmFjaygtMTExMSk7CiAgICAKICAgIHN0ZDo6bWFwPGNoYXIsIGludD4gZGlnaXRfZnJlcXVlbmN5OwogICAgCiAgICBmb3IoaW50IGkgPSAwOyBpIDwgbnVtcy5zaXplKCk7ICsraSkKICAgIHsKICAgICAgICBzdGQ6OnN0cmluZ3N0cmVhbSBzczsKICAgICAgICBzcyA8PCBudW1zW2ldOwogICAgICAgIHN0ZDo6c3RyaW5nIHN0ciA9IHNzLnN0cigpOwogICAgICAgIGlmKGlzZGlnaXQoc3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