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