讨论 / AC,纪念
我要成为大神 2017-11-08 11:25:17
点我顶贴 收藏 删除
#include<iostream>

#include<cstdio>

#include<algorithm>

#include<cstring>

using namespace std;

struct node

{

char name[30];

int classscore;

int roomscore;

char studentgan;

char xibustudent;

int lunwen;

int qian;

} a[105];

int main()

{

int n;

while(scanf("%d",&n)!=EOF)

{

memset(a,0,sizeof(a));

for(int i=0; i<n; i++)

cin>>a[i].name>>a[i].classscore>>a[i].roomscore>>a[i].studentgan>>a[i].xibustudent>>a[i].lunwen;

int sum = 0;

for(int i=0; i<n; i++)

{

if(a[i].classscore>80 && a[i].lunwen>=1)

a[i].qian+=8000;

if(a[i].classscore>85 && a[i].roomscore>80)

a[i].qian+=4000;

if(a[i].classscore>90)

a[i].qian+=2000;

if(a[i].classscore>85 && a[i].xibustudent=='Y')

a[i].qian+=1000;

if(a[i].roomscore>80 && a[i].studentgan=='Y')

a[i].qian+=850;

}

int x ,y;

x = y =0;

for(int i=0; i<n; i++)

{

sum+=a[i].qian;

if(y<a[i].qian)

{

y = a[i].qian;

x = i;

}

}

cout<<a[x].name<<endl;

cout<<y<<endl;

cout<<sum<<endl;

}

return 0;

}

#1 Herobrine@2018-08-09 19:57:54
回复 删除
#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;

}

查看更多回复
提交回复