11 solutions
-
0
题解
这个题用结构体储存每个同学的名字和成绩,然后根据每位同学的成绩进行排序(比如sort排序,cmp大法),最后根据每位同学的分数判断奖项进行输出即可,上代码:
代码
#include<bits/stdc++.h> #include<iostream> #include<algorithm> #include<iomanip> using namespace std; int x[100000000],y[17]; char a[11],b[18]; struct Main{ char a[20]; int cheng; }pp[300]; int cmp(Main x,Main y){ return x.cheng>y.cheng; } int main() { int n; cin>>n; for(int i=0;i<n;i++){ cin>>pp[i].a>>pp[i].cheng; } sort(pp,pp+n,cmp); for(int i=0;i<n;i++){ if(pp[i].cheng==0){ cout<<pp[i].a<<" "<<pp[i].cheng<<" Bad"<<endl; } else if(pp[i].cheng>=1&&pp[i].cheng<200){ cout<<pp[i].a<<" "<<pp[i].cheng<<" Not good"<<endl; }else if(pp[i].cheng>=200&&pp[i].cheng<300){ cout<<pp[i].a<<" "<<pp[i].cheng<<" Bronze medal"<<endl; }else if(pp[i].cheng>=300&&pp[i].cheng<400){ cout<<pp[i].a<<" "<<pp[i].cheng<<" Silver medal"<<endl; }else if(pp[i].cheng>=400){ cout<<pp[i].a<<" "<<pp[i].cheng<<" Gold medal"<<endl; } } return 0; }
Information
- ID
- 110
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- # Submissions
- 211
- Accepted
- 77
- Uploaded By