讨论 / C++ AC struct
Herobrine 2018-08-09 19:56:59
点我顶贴 收藏 删除
#include <iostream>

#include <algorithm>

using namespace std;

struct student{

string name;

int q,b,l,m,h;

char g,x;

}a[101];

int n;

long long sum;

bool cmp(const student a,const student b){

if(a.m != b.m) return a.m > b.m;

return a.h < b.h;

}

int main(){

cin >> n;

for(int i = 1;i <= n;i ++){

cin >> a[i].name >> a[i].q >> a[i].b >> a[i].g >> a[i].x >> a[i].l;

a[i].h = i;

if(a[i].q > 80 && a[i].l >= 1) a[i].m += 8000;

if(a[i].q > 85 && a[i].b > 80) a[i].m += 4000;

if(a[i].q > 90) a[i].m += 2000;

if(a[i].q > 85 && a[i].x == 'Y') a[i].m += 1000;

if(a[i].b > 80 && a[i].g == 'Y') a[i].m += 850;

sum += a[i].m;

}

sort(a + 1,a + 1 + n,cmp);

cout << a[1].name << "\n";

cout << a[1].m << "\n";

cout << sum;

}

查看更多回复
提交回复