第6章-7.找出總分最高的學生 (15分)


給定N個學生的基本信息,包括學號(由5個數字組成的字符串)、姓名(長度小於10的不包含空白字符的非空字符串)和3門課程的成績([0,100]區間內的整數),要求輸出總分最高學生的姓名、學號和總分。

輸入格式:

輸入在一行中給出正整數N(≤10)。隨后N行,每行給出一位學生的信息,格式為“學號 姓名 成績1 成績2 成績3”,中間以空格分隔。

輸出格式:

在一行中輸出總分最高學生的姓名、學號和總分,間隔一個空格。題目保證這樣的學生是唯一的。

輸入樣例:

5 00001 huanglan 78 83 75 00002 wanghai 76 80 77 00003 shenqiang 87 83 76 10001 zhangfeng 92 88 78 21987 zhangmeng 80 82 75 
 

輸出樣例:

zhangfeng 10001 258 
 
 1 # 找出總分最高的學生
 2 # Author: cnRick
 3 # Time : 2020-4-13
 4 n = int(input())  5 maxScoreStu = dict()  6 maxScore = -1
 7 for i in range(n):  8     thisLine = input().split()  9     score = int(thisLine[-1]) + int(thisLine[-2]) + int(thisLine[-3]) 10     if score > maxScore: 11         maxScore = score 12         maxScoreStu['name'] = thisLine[1] 13         maxScoreStu['id'] = thisLine[0] 14         maxScoreStu['score'] = maxScore 15 print("{:s} {:s} {:d}".format(maxScoreStu['name'],maxScoreStu['id'],maxScoreStu['score']))

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM