Advertisement
Guest User

Untitled

a guest
Jun 14th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. const int INF = 1007;
  5. int main()
  6. {
  7.     char sequence[INF];
  8.     int n = strlen(sequence);
  9.     int x =0;
  10.  
  11.     for (int i = 0; i < n; i++)
  12.     {
  13.         cin >> sequence[i];
  14.         if(i !=0 && i%2 == 0)
  15.         {
  16.             if(sequence[i] < sequence[i-2]&& i-2 >= 0)
  17.             {
  18.                 swap(sequence[i],sequence[i-2]);
  19.             }
  20.         }
  21.     }
  22.     for (int i = 0; i < n; i++)
  23.     {
  24.         cout << sequence[i];
  25.     }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement