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