View Code of Problem 114

#include <iostream>
using namespace std;

int main(){
    char s[100],t;
    int k,n,m;
    while(gets(s)!=NULL){
        k=0;
        while(s[k]!='\0'){
            while(!isalpha(s[k]))
                k++;
            n = k;
            while(isalpha(s[k]))
                k++;
            m = k-1;
            for (int i =n; i<=(n+m)/2; i++) {
                t = s[i];
                s[i] = s[n+m-i];
                s[n+m-i] = t;
            }
        }
        printf("%s\n",s);
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 114