题解 | #截取字符串#
截取字符串
http://www.nowcoder.com/practice/a30bbc1a0aca4c27b86dd88868de4a4a
- 定义一个字符串,因为字符串本身也是一个数组,所以使用for循环输出
using namespace std;
int main(){
string s;
cin>>s;
int n;
cin>>n;
for(int i=0;i<n;i++){
cout<<s[i];
}
return 0;
}