文章

119

粉丝

68

获赞

92

访问

20.2k

头像
学生成绩管理 题解:简单模拟
P1052 西安交通大学机试题
发布于2025年2月8日 10:42
阅读数 79

#include <bits/stdc++.h>
using namespace std;

struct Student{
    string id,clas,name;
    double score1,score2,score3,pre;
    Student(string id,string clas,string name,double score1,double score2,double score3):id(id),clas(clas),name(name),score1(score1),score2(score2),score3(score3){
        pre=(score1+score2+score3)/3.0;
    }
    bool operator <(Student b){
        return pre<b.pre;
    }
    void print(){
        cout<<id<<' '<<clas<<' '<<name<<' ';
        printf("%.1lf %.1lf %.1lf %.1lf",score1,score2,score3,pre);
    }
};

int main() {
    int n;
    while(cin>>n){
        std::vector<Student> a;
        while(n--){
            string id,clas,name;
            double score1,score2,score3;
            cin>>id>>clas>>name>>score1>>score2>>score3;
            a.push_back(Student(id,clas,name,score1,score2,score3));
            cout<<a[a.size()-1]...
登录查看完整内容


登录后发布评论

暂无评论,来抢沙发