题解 | #截取字符串#
截取字符串
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;
}
华为题库题解 文章被收录于专栏
牛客华为题库的题解