D.cpp 684 B

12345678910111213141516171819202122232425262728293031
  1. //
  2. // Created by jal on 2019-05-02.
  3. //
  4. #include<bits/stdc++.h>
  5. using namespace std;
  6. int main(){
  7. string s;
  8. while(getline(cin, s)){
  9. int b = 0, e = 0;
  10. for(int i = 0; i < s.size(); i++){
  11. if(i == 0){
  12. if(isalpha(s[i])){
  13. b = i;
  14. }
  15. }
  16. else if (not isalpha(s[i-1]) && isalpha(s[i])){
  17. b = i;
  18. }
  19. if(isalpha(s[i])){
  20. e = i+1;
  21. }else{
  22. if(b != e){
  23. reverse(s.begin()+b, s.begin()+e);
  24. }
  25. b = e = i;
  26. }
  27. }
  28. cout << s << endl;
  29. }
  30. }