fork(2) download
#include 
#include 
#include 
#include 
#include 
#include 

int main(int argc, char** argv)
{
    std::vector 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 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::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;
}
Success #stdin #stdout 0s 3436KB
stdin
Standard input is empty
stdout
Number 1 occurred 2 time(s).
Number 5 occurred 3 time(s).
Number 9 occurred 1 time(s).