题目
代码
class Student:
def __init__(self, sname, mscore, cscore, escore):
self.sname = sname
self.mscore = mscore
self.cscore = cscore
self.escore = escore
def total(self):
return self.mscore + self.cscore + self.escore
def FindMaxScoreStudent(sname,mscore,cscore,escore):
students = []
total = []
for i in range(len(sname)):
students.append( Student(sname[i], mscore[i], cscore[i], escore[i]))
total.append(students[i].total())
student = students[total.index(max(total))]
return student
sname = list(map(str,input("Enter sname:
").split( )))
mscore = list(map(int,input("Enter mscore:
").split( )))
cscore = list(map(int,input("Enter cscore:
").split( )))
escore = list(map(int,input("Enter escore:
").split( )))
student = FindMaxScoreStudent(sname,mscore,cscore,escore)
print(student.sname + ' ' + str(student.mscore) + ' ' + str(student.cscore) + ' ' + str(student.escore))
输入
Enter sname:
jack tom
Enter mscore:
95 84
Enter cscore:
90 75
Enter escore:
85 90
输出
jack 95 90 85