Skip to content

Latest commit

 

History

History
33 lines (25 loc) · 655 Bytes

README.md

File metadata and controls

33 lines (25 loc) · 655 Bytes

See it on Stackoverflow ...

Pretty simple using map!

See the Repl.it

#include <iostream>
#include <map>

int main()
{
    int foo[]{1,1,1,1,4,6,4,7,4};
    std::map<int, int> bar;

    for (auto const &f : foo)
        bar[f]++;

    for (auto const &b : bar)
        std::cout << "The number " << b.first 
                  << "is repeated " << b.second 
                  << "times\n";
}

Expected output:

The number 1 is repeated 4 times
The number 4 is repeated 3 times
The number 6 is repeated 1 times
The number 7 is repeated 1 times