字符串移位-数组
从键盘输入一个字符串L(字符串长度≤36个字符)和一个整数n(1 ≤ n ≤ 36),从该字符串最末位开始逐位移到字串的开头,求移n位后的新字串。
Input
输入第一行为一个字符串L;第二行为一个整数n;
Output
移n位后的新字串
Sample Input
computer
3
Sample Output
tercompu
#include <stdio.h>
#include<string.h>
int main()
{
char a[36], x;
int n, m, i = 1, j;
scanf("%s", &a);
scanf("%d", &n);
m = strlen(a);
for(; i <= n; i++)
{
x = a[m - 1];
for(j = m - 1; j > 0; j--)
{
a[j] = a[j - 1];
}
a[0] = x;
}
printf("%s", a);
}