题解 | 单词倒排

单词倒排

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

#include <iostream>
#include <string>
#include <vector>
#define int long long

using namespace std;

signed main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    vector<string> s(10000);
    char c;
    int i = 0;
    while (cin.get(c) && c != '\n') {
        if (c < 'A' || c > 'Z' && c < 'a' || c > 'z') {
            i++;
            s[i] = " ";
            i ++;
            continue;
        }
        if (c == ' ') {
            i++;
            s[i] = " ";
            i++;
            continue;
        }
        s[i] = s[i] + c;
    }
    for (int j = i; j >= 0; j--) {
        cout << s[j];
    }
    cout << endl;

    return 0;
}
// 64 位输出请用 printf("%lld")

这道题还是写的很纯,不知道有没有什么简单的方法。最近脑子不太好用,需要换个脑子哩()。还有,用vector如果想直接访问读入的话,就要开大点,不然真的会报段错误,别问我怎么知道的。#牛客春招刷题训练营#

#牛客春招刷题训练营#
全部评论
https://www.nowcoder.com/discuss/727521113110073344
点赞 回复 分享
发布于 03-20 12:32 山东

相关推荐

03-16 22:00
武汉大学 C++
幸福的小熊猫想要offer:我阿里投的 c++岗,面试官说自己是做 java 的,c++这辈子才有了
点赞 评论 收藏
分享
03-11 21:46
西北大学 Java
河和静子:这只是实习工资,我学长北大通班博一的,他同学被这家天天发邮件让他去实习,一个月10w
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务