1004

作者: 峡迩 | 来源:发表于2017-07-14 23:15 被阅读0次
    #include<iostream>
    #include<string>
    #include<sstream>
    
    using namespace std;
    
    class Student_grade
    {
    public:
        Student_grade() = default;
        Student_grade(istream &in)
        {
            in >> name >> id >> grade;
        }
        Student_grade(const unsigned g):grade(g){}
        unsigned get_grade() const { return grade; }
        void print()const { cout << name << " " << id << endl; }
    
    private:
        string name;
        string id;
        unsigned grade=0;
    };
    
    int main()
    {
        unsigned n = 0;
        cin >> n;
        Student_grade max;
        Student_grade min(100);
        while (n>0)
        {
            Student_grade st(cin);
            if (max.get_grade() <= st.get_grade())
                max = st;
            if (min.get_grade() >= st.get_grade())
                min = st;
            --n;
        }
    
        max.print();
        min.print();
    
        system("pause");
        return 0;
    }
    

    相关文章

      网友评论

          本文标题:1004

          本文链接:https://www.haomeiwen.com/subject/jatahxtx.html