Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <vector>
- #include <map>
- #include <algorithm>
- using namespace std;
- int main()
- {
- map <string,int> m;
- ifstream in;
- in.open ("input.txt");
- while (!in.eof())
- {
- string str;
- in >> str;
- transform(str.begin(), str.end(), str.begin(), ::tolower);
- m[str]++;
- }
- for (auto it:m)
- {
- cout << it.first <<' '<< it.second << endl;
- }
- multimap <int,string> M;
- for (auto it:m)
- {
- M.insert (make_pair (it.second,it.first));
- }
- for (auto it:M)
- {
- cout << it.first <<' '<< it.second << endl;
- }
- ofstream out;
- out.open ("output.txt");
- for (auto it:M)
- {
- out << it.second<<' ' << it.first<< endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement