华为机试:参数解析

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

int main() {
    string str;
    getline(cin, str);
    vector<vector<char>> para;
    vector<char> temp;
    bool flag = true;
    for (char ch : str) {
        if (ch == ' ' && flag) {
            para.push_back(temp);
            temp.clear();
        }
        else if (ch == '"') {
            flag = flag ^ true;
        }
        else {
            temp.push_back(ch);
        }
    }
    para.push_back(temp);
    temp.clear();
    cout << para.size() << endl;
    for (int i = 0; i < para.size(); i++) {
        for (int j = 0; j < para[i].size(); j++) {
            cout << para[i][j];
        }
        cout << endl;
    }
    return 0;
}

全部评论
多谢大佬的分享吼吼吼
点赞 回复 分享
发布于 2023-03-11 13:27 上海
反手就是一个点赞!
点赞 回复 分享
发布于 2023-03-11 13:09 河北

相关推荐

喝干太平洋:我是大专 我感觉我当时的简历比你好点 就一个vue吗
点赞 评论 收藏
分享
程序员小白条:主要没亮点,项目也是网上的,平平无奇,那只能海投了,奖项总得有一些,然后就是现在最好是前后端都会,自己能做项目并且运维的,要么找星球项目改改,要么找个开源项目改改,自己能拓展功能才是主要的,跟做效率很低很低
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
昨天 13:32
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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