解题思路:需要注意一下,因为PAT无法使用gets,所以使用getline函数,以前那种一个个读入的方法会有错!!!
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
string s;
int main()
{
freopen("t.txt","r",stdin);
int n;
char c,t;
scanf("%d %c",&n,&c);
getchar();
int k=0;
getline(cin,s);
k=s.size();
if(k>=n)
{
for(int i=k-n;i<k;i++)
printf("%c",s[i]);
}else
{
for(int i=0;i<n-k;i++)
printf("%c",c);
for(int i=0;i<k;i++)
printf("%c",s[i]);
}
return 0;
}