往字符串最末尾加前N个字符,然后从第N+1个字符开始输出到末尾
#include <iostream>
#include <string>
using namespace std;
int main()
{
string word;
unsigned int N;
getline(cin, word);
cin >> N;
if (N == 0) {
cout << word << endl;
}
else {
int length = word.size();
for (int i = 0; i < N; ++i) {
word.append(word, 0, N);
}
for (int j = N; j < length + N; ++j) {
cout << word[j];
}
cout << endl;
}
return 0;
}