Skip to content

Instantly share code, notes, and snippets.

@kerolloz
Created September 29, 2018 08:40
Show Gist options
  • Save kerolloz/c2f5255a77d70119937989cfbf4e1503 to your computer and use it in GitHub Desktop.
Save kerolloz/c2f5255a77d70119937989cfbf4e1503 to your computer and use it in GitHub Desktop.
#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