#include<string.h> #include<stdio.h> #include<math.h> int main() { char s[100]; while(gets(s) != NULL) { int i = 0,left,right,j; while(s[i] != '\0') { while(!((s[i]>='a'&&s[i]<='z')||(s[i]>='A'&&s[i]<='Z'))) i++; left = i; while(((s[i]>='a'&&s[i]<='z')||(s[i]>='A'&&s[i]<='Z'))) i++; right = i - 1; for(j = left;j <= (left+right)/2;j++) { char c = s[j]; s[j] = s[left+right-j]; s[left+right-j] = c; } } puts(s); } } |
Double click to view unformatted code.