Given a string S, you are going to shift part of it.
Specifically, a right shift on a string is to move all the characters right but the rightmost characters would be moved to the leftmost.
For example, a shift on "abcd" would result in "dabc".
This problem ask you to implement a function shift(char *start, char *end) that shifts a substring of S starting from start and ending at end.
Reference code:
Note: It is absolutely fine if you don't follow this template.
void shift(char *start, char *end)
{
/* Your code */
}
int main(){
char str[111];
int n,l,r;
scanf("%s",str);
scanf("%d",&n);
while(n--){
scanf("%d%d",&l,&r);
shift(&str[l-1], &str[r-1]);
printf("%s\n", str);
}
printf("%s\n",str);
}
The first line is a string S. (length of S<=20)
The second is a integer n. (n<=10)
The next n lines, each contains two integers l and r.(l<=r<=n)
This means that a shift on S[l-1]S[l]...S[r-1].
If the length of substring is one(l=r), then you should keep the string unchanged.
All these shifts must be done in order.
The resulting string after all n shift operations. There's a newline after the string.