Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- const int INF = 1007;
- int main()
- {
- char sequence[INF];
- int n = strlen(sequence);
- int x =0;
- for (int i = 0; i < n; i++)
- {
- cin >> sequence[i];
- if(i !=0 && i%2 == 0)
- {
- if(sequence[i] < sequence[i-2]&& i-2 >= 0)
- {
- swap(sequence[i],sequence[i-2]);
- }
- }
- }
- for (int i = 0; i < n; i++)
- {
- cout << sequence[i];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement