#include<iostream> #include<string> using namespace std; int main() { string str; while (getline(cin, str)) { int len = str.size(); for (int i = 0, p; i < len; i++) { string s; while (i < len && !isalpha(str[i]))i++; if (i == len) break; p = i; s = str[i] + s; for (i++; i < len&&isalpha(str[i]); i++) s = str[i] + s; str.replace(p, i - p, s); } cout << str << endl; } } |
Double click to view unformatted code.