if使用次数过多……
2024-08-15 18:21:12
发布于:云南
0阅读
0回复
0点赞
狂打if君
#include<bits/stdc++.h>
using namespace std;
struct node{
string name;
int id,score,ping,word,money;
bool stu,west;
}a[105];
bool cmp(node a,node b){
if(a.money != b.money) return a.money > b.money;
else return a.id < b.id;
}
int main(){
int n; cin >> n;
for(int i = 1;i <= n;i++){
char t_stu,t_west;
cin >> a[i].name >> a[i].score >> a[i].ping >> t_stu >> t_west >> a[i].word;
a[i].id = i;
if(t_stu == 'Y') a[i].stu = true;
else a[i].stu = false;
if(t_west == 'Y') a[i].west = true;
else a[i].west = false;
}
for(int i = 1;i <= n;i++){
if(a[i].score > 80 && a[i].word >= 1) a[i].money += 8000;
if(a[i].score > 85 && a[i].ping > 80) a[i].money += 4000;
if(a[i].score > 90) a[i].money += 2000;
if(a[i].score > 85 && a[i].west) a[i].money += 1000;
if(a[i].ping > 80 && a[i].stu) a[i].money += 850;
}
sort(a + 1,a + n + 1,cmp);
cout << a[1].name << "\n" << a[1].money << "\n";
int sum = 0;
for(int i = 1;i <= n;i++) sum += a[i].money;
cout << sum;
return 0;
}
这里空空如也
有帮助,赞一个