Pages

Tuesday, December 21, 2010

UVA Problem#483

Question:

Solution:
int main(){
   
    string line;
   
    while(getline (cin,line)) {
                  int t = line.size();
                  int count;
                  string sub;
                  for(int i=0;i<t;i++){
                       count=0;
                       if(line[i]!=' '){    
                                while(line[i+count]!=' ' && i+count<t){
                                       count++;         
                                }
                                for(int j=(i+count)-1;i<=j && j<t;j--){
                                          cout<<line[j];
                                }    
                                i+=count-1;  
                       }else{
                            cout<<line[i];
                       }
                  }
                  cout<<endl;
    }
   
 return 0;  
}

No comments:

Post a Comment