题解 | #截取字符串#

截取字符串

http://www.nowcoder.com/practice/a30bbc1a0aca4c27b86dd88868de4a4a

#include <bits/stdc++.h>
#include <iostream>
#include <string>

using namespace std;

int main(){
    string str = "";
    getline(cin, str);
    int num = 0;
    cin >> num;
    
    string res = "";
    for(char c : str){  
        if(num == 0) break;
        res += c;
        num--;
    }
    
    cout << res << endl;
    
    return 0;
}
华为题库题解 文章被收录于专栏

牛客华为题库的题解

全部评论

相关推荐

牛客83265014...:完了,连现在都没开始面,13号投的是不是晚了
秋招的第一个offer,...
点赞 评论 收藏
分享
迷茫的大四🐶:哇靠,哥们,啥认证啊,副总裁实习,这么有实力嘛
一起聊美团
点赞 评论 收藏
分享
存一下准备挨个投一下
从明天开始狠狠卷JV...:mark
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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