天天看點

牛客網程式設計題——操作序列

牛客網程式設計題——操作序列

從原數組的末尾往前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])