题解 | 不要三句号的歪

不要三句号的歪

https://www.nowcoder.com/practice/7cbb7d96fb354f7995d9af1ccf8906b4

活动地址: 牛客春招刷题训练营 - 编程打卡活动

#include <iostream>

#include <sstream>

#include <string>

#include <vector>

using namespace std;

//如果我们想得到类似于split 函数的效果

//可以使用 stringstream 与getline 结合的方法

int main() {

    string s;

    getline(cin, s);

    vector<string> ve;

    stringstream ss(s);

    string str;

    while(getline(ss, str, ',')){

        ve.push_back(str);

    }

    long long a = stoll(ve[1]);

    long long b = stoll(ve[3]);

    long long res = b - a - 1;

    cout << res;

}

活动地址: 牛客春招刷题训练营 - 编程打卡活动

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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