无脑调用标准库
#include<iostream>
#include<vector>
#include<algorithm>
#include<sstream>
int main(int argc, char const *argv[])
{
std::vector<std::string> snum;
std::string stmp;
std::string mstmp;
while (std::cin >> stmp)
{
for(auto c : stmp)
{
if ( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') )
{
mstmp.push_back(c);
}
else{
//不是字母的值,进行写入,可以写入空字符,空字符默认不会保存在vector
snum.push_back(mstmp);
mstmp.clear();
}
}
//最后一个字符是字母,写入vector
snum.push_back(mstmp);
mstmp.clear();
}
std::reverse(snum.begin(), snum.end());
for (auto s : snum)
{
std::cout << s << " ";
}
return 0;
}