Advertisement
SomniP

Сортировка символов в строке и строк по алфавиту

Jan 14th, 2019
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <string>
  4. #include <vector>
  5. #include <algorithm>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     SetConsoleCP(1251);
  12.     SetConsoleOutputCP(1251);
  13.     system("color 0A");
  14.  
  15.     string str("привет!");
  16.     sort(str.begin(), str.end());
  17.     cout << str << endl;
  18.     cout << endl;
  19.  
  20.     vector<string> box;
  21.     box.push_back("кошка");
  22.     box.push_back("поле");
  23.     box.push_back("высота");
  24.     box.push_back("крот");
  25.     box.push_back("топор");
  26.     box.push_back("брод");
  27.     box.push_back("пешеход");
  28.     box.push_back("короб");
  29.     sort(box.begin(), box.end());
  30.     for (const auto &strng : box)
  31.     {
  32.         cout << strng << endl;
  33.     }
  34.     cout << endl;
  35.  
  36.     system("pause");
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement