Created
September 29, 2018 08:40
-
-
Save kerolloz/c2f5255a77d70119937989cfbf4e1503 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int main (){ | |
int n;cin >> n; | |
for (int i = 0; i < n; ++i) { | |
int t; | |
cin >> t; | |
bool englishFound = false; | |
string before = "", after = "", word = ""; | |
string all = ""; | |
for (int k = 0; k < t; ++k) { | |
string s; | |
cin >> s; | |
if(isalpha(s[0])) {englishFound = 1; word = s; all += s + " ";} | |
else if(englishFound) {after += s + " "; all += s + " ";} | |
else{ before += " " + s; all += s + " "; } | |
} | |
if(!englishFound) for (int k = 0; k < all.size()-1; ++k) cout << all[k]; | |
else cout << after << word << before; | |
cout << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment