#include<stdio.h> #include<string.h> #include<math.h> #include<algorithm> using namespace std; int main() { char str[10000]; int i,j; while(gets(str)) { for(i=0; i<strlen(str); i++) { if((str[i]<='Z' && str[i]>='A')||(str[i]<='z' && str[i]>='a')) { for(j=i; j<strlen(str); j++) { if(!((str[j]<='Z' && str[j]>='A')||(str[j]<='z' && str[j]>='a'))) { // printf("%d",j); break; } } // printf("%d",j); int temp=j; for(; j>i; j--) { printf("%c",str[j-1]); } i=temp-1; } else { // printf("-"); printf("%c",str[i]); } } printf("\n"); } } |
Double click to view unformatted code.