#include<stdio.h> #include<math.h> #include<string.h> int main() { char s[100]; while(gets(s) != NULL) { int i = 0,left,right,k; while(s[i]) { 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(k = left;k <= (left+right)/2;k++) { char t = s[k]; s[k] = s[left+right-k]; s[left+right-k] = t; } } puts(s); } return 0; } |
Double click to view unformatted code.