#44387: python 淺顯易懂(比較長)


suyueh (suyueh)

School : No School
ID : 272111
IP address : [101.9.53.130]
Last Login :
2025-03-17 21:48:18
b964. 1. 成績指標 -- 2016年3月apcs | From: [101.10.92.238] | Post Date : 2024-12-01 22:21

p = int(input())
list1 = input()
list2 = list1 # 保留原始輸入
list1 = list(map(int, list1.split())) # 轉換為整數列表
h, l, x, y = 101, 0, 0, 0

for score in list1:
if score > 59 and score < h:
h = score
elif score < 60 and score > l:
l = score

if score > 59:
x += 1
elif score < 60:
y += 1

# 將 list2 轉換為數字列表並排序
list2 = list(map(int, list2.split()))
list2.sort() # 由小到大排序

print(*list2) # 輸出排序後的 list2

if x == len(list1):
print("best case")
print(h)
elif y == len(list1):
print(l)
print("worst case")
else:
print(l)
print(h)
 
#45499: Re: python 淺顯易懂(比較長)


henryko (henry)

School : 臺北市立內湖國民小學
ID : 273167
IP address : [123.252.21.196]
Last Login :
2025-03-16 20:48:30
b964. 1. 成績指標 -- 2016年3月apcs | From: [123.252.21.196] | Post Date : 2025-03-09 19:08

哥們你這樣會NA阿

 
ZeroJudge Forum