- 具体注意事项看注释
#include<bits/stdc++.h> using namespace std; int main(){ string s; while(cin>>s){ int n ; cin>>n; copy(s.begin(), s.begin()+n, ostream_iterator<char>(cout));//用copy,通过ostream_iterator<char>(cout)输出 cout<<endl; } }
#include<bits/stdc++.h> using namespace std; int main(){ string s; while(cin>>s){ int n ; cin>>n; copy(s.begin(), s.begin()+n, ostream_iterator<char>(cout));//用copy,通过ostream_iterator<char>(cout)输出 cout<<endl; } }