题解 | #截取字符串#再简单的问题,我都会认证对待
截取字符串
https://www.nowcoder.com/practice/a30bbc1a0aca4c27b86dd88868de4a4a
#include <iostream> #include <string> using namespace std; int main(){ string str; getline(cin,str); int k; cin >> k; cout << str.substr(0,k) << endl; return 0; }