#include <stdio.h>
#include <string.h>
int main()
{
int n;
char ch;
scanf("%d %c",&n,&ch);
getchar();
char s[100001],a[100001];
gets(s);
int t=strlen(s);
int k=0;
if(n>t)
{
for(int i=0;i<n-t;i++)
a[i]=ch;
for(int i=n-t;i<n;i++)
{
a[i]=s[k];
k++;
}
puts(a);
}//第一个if就是在t<n的情况,直接就是差多少,就把ch存入数组中,然后再存入输入的数组。
else
{
t=t-1;
while(n--)
{
a[k]=s[t];
k++;
t--;
}//t>n,从后存入数组,然后反向输出
for(int i=k-1;i>=0;i--)
printf("%c",a[i]);
}
return 0;
}
04-21
452
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交