#include <iostream> #include <cstring> #include <cmath> #include <algorithm> using namespace std; int main() { char str[100]; int i,j,k,n; while(gets(str)) { string word; int len = strlen(str); for(i = 0; str[i] != '\0' ; i++) { if((str[i] >= 'a' && str[i] <= 'z') || (str[i] >= 'A' && str[i] <= 'Z')) { word += str[i]; } else { int len = word.length(); for(j = (len-1) ; j >= 0; j--) { cout << word[j]; } cout << str[i] ; word = ""; } } len = word.length(); for(j = len-1; j >= 0; j--) { cout << word[j]; } cout <<endl; } return 0; } |
Double click to view unformatted code.