题解 | #单词倒排#

单词倒排

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

#include <bits/stdc++.h>
using namespace std;

int main() {
    string str;
    getline(cin, str);
    vector<string> vec;
    string word = "";
    for(int i=0; i<str.size(); i++){
        if(isalpha(str[i])){
            word += str[i];
        }
        else{
            vec.push_back(word);
            word = "";
        }
    }
    vec.push_back(word);
    reverse(vec.begin(), vec.end());
    for(auto i:vec) cout << i <<" ";
    cout << endl;
    return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务