写题
`#define _CRT_SECURE_NO_WARNINGS
include
include
include
using namespace std;
int main()
{
string input;
int length;
char put;
cin >> length;
cin.ignore();
put = cin.get();
cin.ignore(numeric_limits
getline(cin, input);
if (length < input.size())//判断要求字符串长度是否超出限制
{
string str = input.substr(input.size() - length);
cout << str << endl;
return 0;
}
input.insert(0, length - input.size(), put);
cout << input << endl;
return 0;
}`
cin后面跟getline可能会跳过,要加 cin.ignore()来解决

浙公网安备 33010602011771号