(一直出現您的程式被監控系統中斷,可能是程式無法正常結束所導致。)
while True:
L=[]
n=int(input())
best=0
worst=n-1
for i in range(n):
a=int(input())
L.append(a)
L.sort(reverse=False)
for i in range(n):
if L[i]>=60:
break
best=i
for i in range(n-1,-1,-1):
if L[i]<60:
break
worst=i
for i in range(n):
if i==n-1:
print(L[i])
break
print(L[i],end=" ")
if L[0]>=60:
print("best case")
else:
print(L[best])
if L[n-1]<60:
print("worst case")
else:
print(L[worst])
(一直出現您的程式被監控系統中斷,可能是程式無法正常結束所導致。)
while True:
L=[]
n=int(input())
best=0
worst=n-1
for i in range(n):
a=int(input())
L.append(a)
L.sort(reverse=False)
for i in range(n):
if L[i]>=60:
break
best=i
for i in range(n-1,-1,-1):
if L[i]<60:
break
worst=i
for i in range(n):
if i==n-1:
print(L[i])
break
print(L[i],end=" ")
if L[0]>=60:
print("best case")
else:
print(L[best])
if L[n-1]<60:
print("worst case")
else:
print(L[worst])
你的try except呢?
你這樣是無限迴圈ㄟ