题解 | #单词倒排#

单词倒排

https://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836

#include <cctype>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

vector<string> v;

int main() {
    string tmp;
    string s;
    getline(cin, s);
    for (auto c : s) {
        if(isalpha(c)) tmp += c;
        else {
            v.push_back(tmp);
            tmp = "";
        }
    }
    v.push_back(tmp);

    for (auto it = v.rbegin(); it != v.rend(); it++) {
        cout << *it << " ";
    }
}

全部评论

相关推荐

07-29 12:14
门头沟学院 Java
程序员小白条:oppo不用想了,经常看92都挂的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务