题解 | #截取字符串#
截取字符串
http://www.nowcoder.com/practice/a30bbc1a0aca4c27b86dd88868de4a4a
#include<iostream>
using namespace std;
int main()
{
string s;
int d;
while(cin>>s>>d)
{
string res;
int i=0;
while(d--)
{
if(s[i]=='\0')
{
break;
}
else
{
res.push_back(s[i]);
i++;
}
}
cout<<res<<endl;
}
return 0;
}