2018年1月13日 星期六

UVA Q483 - Word Scramble

#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
char a[20000];
int b;
while(gets(a)){
    b=0;
    for(int x=0;x<strlen(a);x++){
        if(a[x]==' '){
            for(int y=x-1;y>=b;y--){
                cout<<a[y];
            }
            b=x+1;
            cout<<' ';
        }else if(x==strlen(a)-1){
            for(int y=x;y>=b;y--){
                cout<<a[y];
            }
        }
    }
    cout<<endl;
}

system("pause");
return 0;
}

沒有留言:

張貼留言