我这一题存在一定遗憾,方法很暴力很low,每输入一个,就比较一次,记录最高分与最低分。然后直接暴力检索事先准备好的 list表,找到对应分数,然后输出。希望有大牛能写出更优雅的解法,请不吝赐教,非常感谢!
num = int(input())
list1 = []
high = 0
low = 100
high_student=''
low_student=''
for x in range(num) :
x = list(input().split())
if int(x[2]) <= low:
low = int(x[2])
if int(x[2]) >= high:
high = int(x[2])
list1.extend(x)
for x in range(len(list1)):
if list1[x]==str(high):
high_student = list1[x-2] + ' ' +list1[x-1]
if list1[x] == str(low):
low_student = list1[x - 2] + ' ' + list1[x - 1]
print(high_student)
print(low_student)