
思路:
這題比較簡單,我的思路是將成績用一個串列存盤,再以成績為鍵,將其他的資訊存盤到一個字典里,這樣找出最大和最小的成績后,以成績訪問字典的值,并列印輸出,
代碼
n = int(input()) # 學生人數
s_date = {} # 學生資訊
scores = [] # 分數
for i in range(n):
s_name, s_id, score = input().split(" ")
score = int(score)
scores.append(score)
s_date[score] = [s_name, s_id]
max_stu = s_date[max(scores)]
min_stu = s_date[min(scores)]
print(f"{max_stu[0]} {max_stu[1]}")
print(f"{min_stu[0]} {min_stu[1]}")
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/163630.html
標籤:Python
上一篇:django時區問題
