#include<iostream> #include<string.h> #include<algorithm> using namespace std; int main(){ //string a; char a[100]; while(gets(a)){ for(int i=0;i<=strlen(a);i++){ if(a[i]==' '){ for(int j=i-1;j>=0;j--){ if(a[j]==' '){ break; } else cout<<a[j]; } cout<<" "; } else if(a[i]=='\0'){ for(int j=i-1;j>=0;j--){ if(a[j]==' '){ break; } else cout<<a[j]; } } } cout<<'\n'; } } |
Double click to view unformatted code.