天天看点

牛客网编程题——操作序列

牛客网编程题——操作序列

从原数组的末尾往前2个2个跳 然后再跳向末尾 同样是2个2个跳

n = int(input())
l = input().split(' ')
resstr = ''
index = n - 1
if n % 2 == 0:
    while index >= 1:
        resstr += l[index]
        resstr += ' '
        index -= 2
    index = 0
    while index < n - 1:
        resstr += l[index]
        resstr += ' '
        index += 2
    print(resstr[:-1])
        
else:
    while index >= 0:
        resstr += l[index]
        resstr += ' '
        index -= 2
    index = 1
    while index < n-1:
        resstr += l[index]
        resstr += ' '
        index += 2
    print(resstr[:-1])