c++题解 | #单词倒排 10行代码#
单词倒排
http://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836
#include <iostream>
#include <vector>
using namespace std;
int main(){
vector<string> str(100);
int j = 0;
string ss;
getline(cin, ss);
for(int i = 0; i < ss.size(); ++i){
if(!isalpha(ss[i]))
continue;
while(isalpha(ss[i]))
str[j] += ss[i++];
j++;
}
for(int i = j - 1; i >= 0; --i)
cout << str[i] << ' ';
}