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. getchar();
  18. for(int i=0; i<n; i++){
  19. string aux;
  20. getline(cin, aux);
  21. cout << aux << endl;
  22. vetor.push_back(aux);
  23. }
  24. for(int t = 0; t<n; t++){
  25. string parse;
  26. vector<string> aux;
  27. for(int i=0; i<vetor[t].size(); i++){
  28. if(vetor[t][i]==' '){
  29. swap(parse[parse.size()-1], parse[0]);
  30. if(parse[parse.size()-1]>='A' && parse[parse.size()-1]<='Z'){
  31. parse[parse.size()-1] = parse[parse.size()-1]+('a'-'A');
  32. parse[0] = parse[0] - ('a'-'A');
  33. }
  34. parse+='ay';
  35. aux.push_back(parse);
  36. parse.clear();
  37. continue;
  38. }
  39. parse+=vetor[t][i];
  40. }
  41. if(parse.size()>0){
  42. swap(parse[parse.size()-1], parse[0]);
  43. if(parse[parse.size()-1]>='A' && parse[parse.size()-1]<='Z'){
  44. parse[parse.size()-1] = parse[parse.size()-1]+('a'-'A');
  45. parse[0] = parse[0] - ('a'-'A');
  46. }
  47. aux.push_back(parse);
  48. parse.clear();
  49. }
  50. print(aux);
  51. }
  52. return 0;
  53. }
Success #stdin #stdout 0s 15240KB
stdin
1
Hello world
stdout
Hello world
Oellhy dorlw