|
|
вернуться в форумmy simple accepted code #include <iostream> #include <iomanip> #include <map> #include <vector> #include <cmath> #include <vector> #include <algorithm> #include <cmath> using namespace std; int letter(char c) { return (('a'<=c&&c<='z')||('A'<=c&&c<='Z')); } int main() { //freopen("a","r",stdin); string s; while(getline(cin,s)) { vector<int> l,r; for (size_t i=0;i<s.length();i++) { if (letter(s[i])) { if (!i||!letter(s[i-1])) { l.push_back(i); } if (i+1==s.length()||!letter(s[i+1])) { r.push_back(i+1); } } } for (int i=0;i<l.size();i++) { reverse(s.begin()+l[i],s.begin()+r[i]); } cout << s << endl; } return 0; } |
|
|