

这道题直接根据题意用结构体枚举就完了,最后找到ID最小的输出就行;
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Student{
char name[30];
int fgrade,cgrade;
char ad,pro;
int thesis;
int money;
int ID;
Student():money(0){}
}st[105];
bool cmp(Student a,Student b){
return a.money>b.money;
}
int main(){
int n;
scanf("%d",&n);
int sum=0;
for(int i=0;i<n;i++){
st[i].ID=i+1;
scanf("%s %d %d %c %c %d",st[i].name,&st[i].fgrade,&st[i].cgrade,&st[i].ad,&st[i].pro,&st[i].thesis);
if(st[i].fgrade>80&&st[i].thesis>=1){
st[i].money+=8000;
sum+=8000;
}
if(st[i].fgrade>85&&st[i].cgrade>80){
st[i].money+=4000;
sum+=4000;
}
if(st[i].fgrade>90){
st[i].money+=2000;
sum+=2000;
}
if(st[i].fgrade>85&&st[i].pro=='Y'){
st[i].money+=1000;
sum+=1000;
}
if(st[i].cgrade>80&&st[i].ad=='Y'){
st[i].money+=850;
sum+=850;
}
}
sort(st,st+n,cmp);
int Max=st[0].money;
int t=0x3f3f3f;
int b;
for(int i=0;i<n;i++){
if(Max==st[i].money){
if(st[i].ID<t){
t=st[i].ID;
b=i;
}
}
}
printf("%s\n%d\n%d\n",st[b].name,st[b].money,sum);
return 0;
}
本文介绍了一种使用C++结构体和排序算法来计算学生奖学金的方法。通过输入学生的各项成绩和条件,程序能够准确地计算出每位学生的奖学金总额,并找出获得最高奖学金的学生。此算法考虑了多个奖学金评定标准,如课程成绩、论文发表、专业和学术表现等。
&spm=1001.2101.3001.5002&articleId=100856371&d=1&t=3&u=ab0733f1cf824d11bf9f9cff3d81d259)
878

被折叠的 条评论
为什么被折叠?



