#include<iostream> #include<vector> #include<string> #include <algorithm> #include <math.h> using namespace std; int main() { string s; while(getline(cin,s)) { bool flag = false; vector<char> v1; vector<char> v2; for (int i = 0; i < s.size(); i++) { if ((s[i] <= 'z' && s[i] >= 'a') || (s[i] >= 'A' && s[i] <= 'Z')) { v1.push_back(s[i]); flag = true; } else { if (flag) { for (int j = v1.size() - 1; j >= 0; j--) { v2.push_back(v1[j]); } flag = false; v1.clear(); } v2.push_back(s[i]); } } if(flag){ for (int j = v1.size() - 1; j >= 0; j--) { v2.push_back(v1[j]); } } for (int i = 0; i < v2.size(); i++) { cout << v2[i] ; } cout << endl; } return 0; } |
Double click to view unformatted code.