fork download
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. // your code goes here
  7. map<int,int> c;
  8. std::for_each(istream_iterator<int>(cin), istream_iterator<int>(), [&c](int x){c[x]++;});
  9. std::for_each(c.begin(),c.end(), [](auto &&r){cout << r.first<<"->"<<r.second<<endl;});
  10. return 0;
  11. }
Success #stdin #stdout 0s 4428KB
stdin
1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1
stdout
1->2
2->2
3->2
4->2
5->2
6->2
7->2
8->2
9->2
10->1