题解 | #单词倒排#
单词倒排
http://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
while(getline(cin,s)){
string ans;
for(int i=s.length() - 1;i>=0;i--){
string tmp;
while(isalpha(s[i])&&i>=0){
tmp=s[i]+tmp;
i--;
}
ans +=(tmp+" ");
}
ans=ans.substr(0,ans.length()-1);
cout<<ans<<endl;
}
}