题解 | #截取字符串#
截取字符串
https://www.nowcoder.com/practice/a30bbc1a0aca4c27b86dd88868de4a4a
// HJ46-2 截取字符串.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
int k;
while (cin >> s>>k)
{
cout << s.substr(0, k) << endl;
}
return 0;
}
查看2道真题和解析
