7-3 银行业务队列简单模拟 (25分)

num = input()
num_list = num.split(" ")
for i in range(0, len(num_list)):
    num_list[i] = int(num_list[i])
List, List1, List2 = [], [], []
Range = num_list.pop(0)
j = 0
for i in num_list:
    if i % 2 == 1:
        List1.append(i)
    if i % 2 == 0:
        List2.append(i)
for i in num_list:
    if len(List1) != 0 :
        List.append(List1.pop(0))
        j += 1
    if len(List2) != 0 and j % 2 == 0:
        List.append(List2.pop(0))
        j = 0
len1 = len(List)
for i in range(len1):
    if(i == len1 - 1):
        print(List[i], end = "")
    else :
        print(List[i], end =" ")
        

        
        

你可能感兴趣的:(PTA,c++,python)