Advertisement
Guest User

файл

a guest
Apr 27th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <vector>
  5. #include <map>
  6. #include <algorithm>
  7. using namespace std;
  8. int main()
  9. {
  10. map <string,int> m;
  11. ifstream in;
  12. in.open ("input.txt");
  13. while (!in.eof())
  14. {
  15. string str;
  16. in >> str;
  17. transform(str.begin(), str.end(), str.begin(), ::tolower);
  18. m[str]++;
  19. }
  20. for (auto it:m)
  21. {
  22. cout << it.first <<' '<< it.second << endl;
  23. }
  24. multimap <int,string> M;
  25. for (auto it:m)
  26. {
  27. M.insert (make_pair (it.second,it.first));
  28. }
  29. for (auto it:M)
  30. {
  31. cout << it.first <<' '<< it.second << endl;
  32. }
  33. ofstream out;
  34. out.open ("output.txt");
  35. for (auto it:M)
  36. {
  37. out << it.second<<' ' << it.first<< endl;
  38. }
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement