zoukankan      html  css  js  c++  java
  • 总分最高的学生姓名和各科成绩

    题目

    代码

    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

  • 相关阅读:
    iptables命令参数简介
    在linux下开启IP转发的方法
    Linux配置IP路由
    NAT转换
    JS实验案例
    Ubuntu kylin优麒麟root用户与静态网络设置
    非对称加密-RSA
    对称加密-DES
    DM5详解
    Visio的安装教程
  • 原文地址:https://www.cnblogs.com/sinlearn/p/12830693.html
Copyright © 2011-2022 走看看