#include<bits/stdc++.h>//偷懒的万能头 
using namespace std;
struct student{
    string name;//姓名 
    int score1,score2;//期末分数、班级评议分 
    char id1,id2; //干部、西部 
    int count; //论文数 
    int money; //奖学金 
}stu[101]; 
bool cmp(const student &x,const student &y){
    return x.money>y.money;//根据奖学金排序 
}
/*
1) 院士奖学金,每人8000元,期末平均成绩高于80分(>80),并且在本学期内发
   表1篇或1篇以上论文的学生均可获得;
2) 五四奖学金,每人4000元,期末平均成绩高于85分(>85),并且班级评议成绩
   高于80分(>80)的学生均可获得;
3) 成绩优秀奖,每人2000元,期末平均成绩高于90分(>90)的学生均可获得;
4) 西部奖学金,每人1000元,期末平均成绩高于85分(>85)的西部省份学生均可获得;
5) 班级贡献奖,每人850元,班级评议成绩高于80分(>80)的学生干部均可获得;
*/
int main(){
    int n,total=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>stu[i].name>>stu[i].score1>>stu[i].score2>>stu[i].id1>>stu[i].id2>>stu[i].count;
        //无脑if 
        if(stu[i].score1>80 && stu[i].count>=1)
            stu[i].money+=8000;
        if(stu[i].score1>85 && stu[i].score2>80)
            stu[i].money+=4000;
        if(stu[i].score1>90)
            stu[i].money+=2000;
        if(stu[i].score1>85 && stu[i].id2=='Y')
            stu[i].money+=1000;
        if(stu[i].score2>80 && stu[i].id1=='Y')
            stu[i].money+=850; 
        total+=stu[i].money;//总奖学金累加 
    }
    sort(stu+1,stu+n+1,cmp);
    cout<<stu[1].name<<endl<<stu[1].money<<endl<<total;
    return 0;
}

1 条评论

  • @ 2021-05-29 15:06:30

    是不是要用char[]来代替string?
    另外,求最大值直接遍历就够了,不必用排序。

  • 1

信息

ID
1001
难度
5
分类
模拟 点击显示
标签
递交数
39063
已通过
12711
通过率
33%
被复制
121
上传者