daily pastebin goal
26%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top