在开始变量和结束变量中所做的更改将反映在 fli 列表中。这背后的原因是什么?
flight = (input("Enter arrival time and departure time of flight : ").split())
fl=[]
while flight != []:
fl.append(flight)
flight = (input("Enter arrival time and departure time of flight : ").split())
fl = sorted(fl)
fli= []
for i in fl:
f = []
f.append(list(map(int,i[0].split(":"))))
f.append(list(map(int, i[1].split(":"))))
fli.append(f)
runway = 0
max_runway = 0
fli = sorted(fli)
arrival = []
departure = []
for i in fli:
arrival.append(i[0])
departure.append(i[1])
start = fli[0][0]
max_time = start
for i in fli:
for j in i:
if j > max_time:
max_time = j
end = max_time
end[1] += 1
if end[1] % 60 == 0:
end[0] += 1
end[1] = 0
if end[0] % 24 == 0:
end[0] = 0
while start != end:
if start in arrival:
runway += 1
if start in departure:
runway -= 1
if max_runway < runway:
max_runway = runway
start[1] += 1
if start[1] % 60 == 0:
start[0] += 1
start[1] = 0
if start[0] % 24 == 0:
start[0] = 0
print(max_runway)
fli 列表之前,而循环是:[[[9, 15], [9, 25]], [[9, 20], [9, 45]], [[9, 30], [9, 35]], [[9, 30], [9, 38]], [[9, 35], [9, 40]]]
fli 列表在 while 循环之后是 :[[[9, 46], [9, 25]], [[9, 20], [9, 46]], [[9, 30], [9, 35]], [[9, 30], [9, 38]], [[9, 35], [9, 40]]]
翻过高山走不出你
慕雪6442864
茅侃侃
相关分类