• [YTU]_2499( 处理成绩(c++类训练))


    题目描述

    小平帮老师处理期末成绩时遇到了问题。他需要计算每个同学的平均成绩,并判断他们是否通过了期末考试不及格成绩(<60),若都通过才能pass,若没通过要说明是哪几科未通过。因此他需要两个函数,一个求平均成绩(不考虑小数),另一个判断是否通过考试,通过输出pass,否则输出未通过的科目。请你们帮帮他!

    期末包括Chinese,Math,English三门课程。

    输入

    输入学号,并输入三个个科目成绩,三个科目名称分别用Chinese,Math,English来表示

    输出

    输出学号,并输出与学号对应的平均成绩,和挂科科目(全过输出一个pass)。

    每个输出项占一行,挂科科目每个也占一行。

    样例输入

    1001 60 60 60

    样例输出

    student:1001
    60
    pass

    提示

    使用int类型,不考虑小数。

    #include <iostream>
    using namespace std;
    class S
    {
    public:
        int score();
        void jige();
        int num;
        int c;
        int m;
        int e;
    };
    int S::score()
    {
        return (c+m+e)/3;
    }
    void S::jige()
    {
        cout<<"student:"<<num<<endl;
        cout<<score()<<endl;
        if(c<60||m<60||e<60)
        {
            if(c<60)
            cout<<"Chinese"<<endl;
            if(m<60)
                cout<<"Math"<<endl;
            if(e<60)
                cout<<"English"<<endl;
        }
        else
            cout<<"pass"<<endl;
    }
    int main()
    {
        S s;
        cin>>s.num>>s.c>>s.m>>s.e;
        s.jige();
        return 0;
    }

  • 相关阅读:
    远程下载文件并设置进度显示
    python调用函数超时设置
    Ubuntu安装PostgreSQL
    sessionStatMap is full
    LdapTemplate忽略ssl证书
    MySQL5.6 Online DDL
    Mysql5.7编译调试(windows环境)
    Disruptor
    mybatis generator自定义文件后缀名
    maven占位符$变量无法替换
  • 原文地址:https://www.cnblogs.com/sxy201658506207/p/7586368.html
Copyright © 2020-2023  润新知