#include <iostream> using namespace std; int main() { string s;cin>>s; int k;cin>>k; for(int i = 0;i<k;i++){ cout<<s[i]; } return 0; } // 64 位输出请用 printf("%lld")
题目要求输出前k个字符,从前遍历字符串输出即可。
#include <iostream> using namespace std; int main() { string s;cin>>s; int k;cin>>k; for(int i = 0;i<k;i++){ cout<<s[i]; } return 0; } // 64 位输出请用 printf("%lld")
题目要求输出前k个字符,从前遍历字符串输出即可。