1问题描述
要用K字符旋转字符串意味着从头开始剪切这些字符并将它们传送到结尾。 如果K为负数,则相反的字符应从末尾转移到开头。
input:数据将包含第一行中的测试用例数。
以下行将包含数字K和一些由空格分隔的字符串S - 每行一对。
字符串S只包含小拉丁字母。 K的绝对值不会超过S长度的一半。
答案应包含按照上述规则旋转的字符串,用空格分隔。
input data:
2
3 forwhomthebelltolls
-6 verycomplexnumber
answer:
whomthebelltollsfor numberverycomplex
2代码
numberInput=int(input())
summary=[]
for i in range(numberInput):
lineInput=input().split()
forwardPart=lineInput[1][0:int(lineInput[0])]
backPart=lineInput[1][int(lineInput[0]):]
answer=backPart+forwardPart
summary.append(answer)
print(*summary)