Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <map>
- using namespace std;
- int main()
- {
- freopen("input.txt", "r", stdin);
- map<string, int>q;
- string str, last;
- while (cin >> str){
- q[str]++;
- last = str;
- }
- int needCount = q[last];
- for (auto it = q.begin(); it != q.end(); it++) {
- if ((it->second) == needCount)
- cout << it->first << " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment