fork(1) download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. void print(vector<string> &vetor){
  6. for(int i=0; i<vetor.size(); i++){
  7. if(i!=0) cout << " ";
  8. cout << vetor[i];
  9. }
  10. cout << endl;
  11. }
  12.  
  13. int main () {
  14. int n;
  15. cin >> n;
  16. vector<string> vetor;
  17. for(int i=0; i<n; i++){
  18. string aux;
  19. getline(cin, aux);
  20. vetor.push_back(aux);
  21. }
  22. for(int t = 0; t<n; t++){
  23. string parse;
  24. vector<string> aux;
  25. for(int i=0; i<vetor[t].size(); i++){
  26. if(vetor[t][i]==' '){
  27. swap(parse[parse.size()-1], parse[0]);
  28. if(parse[parse.size()-1]>='A' && parse[parse.size()-1]<='Z'){
  29. parse[parse.size()-1] = parse[parse.size()-1]+('a'-'A');
  30. parse[0] = parse[0] - ('a'-'A');
  31. }
  32. parse+='ay';
  33. aux.push_back(parse);
  34. parse.clear();
  35. continue;
  36. }
  37. parse+=vetor[t][i];
  38. }
  39. if(parse.size()>0){
  40. swap(parse[parse.size()-1], parse[0]);
  41. if(parse[parse.size()-1]>='A' && parse[parse.size()-1]<='Z'){
  42. parse[parse.size()-1] = parse[parse.size()-1]+('a'-'A');
  43. parse[0] = parse[0] - ('a'-'A');
  44. }
  45. aux.push_back(parse);
  46. parse.clear();
  47. }
  48. print(aux);
  49. }
  50. return 0;
  51. }
Success #stdin #stdout 0s 15240KB
stdin
1
Hello world
stdout