kej

6. Сортировка слова в лексикографическом порядке методом “пу

kej
Mar 2nd, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int main ()
  6. {
  7.     char str[256];
  8.     int j;
  9.     bool boo = true;
  10.     cin>>str;
  11.     for (int i=0;i<strlen(str)&&boo;i++)
  12.     {
  13.         boo = false;
  14.         for (j=0;j<strlen(str) - i -1;j++)
  15.         {
  16.             if (str[j] > str[j+1])
  17.             {
  18.                 swap(str[j],str[j+1]);
  19.                 boo=true;
  20.             }
  21.         }
  22.        
  23.     }
  24.     cout<<str<<endl;
  25. }
Add Comment
Please, Sign In to add comment