讨论 / AC C++ 直接算的
silentrain 2017-11-18 11:21:23
点我顶贴 收藏 删除
#include <iostream>

#include <string>

#include <cstring>

#define max(a,b) a>=b?a:b

using namespace std;

int main(){

int n;

cin>>n;

string name,namen,gb,xx;

int qm,py,lw,jj=0,ans=0,c=0;

int sum[n+1];

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

sum[i]=0;

cin>>name>>qm>>py>>gb>>xx>>lw;

if(qm>80&&lw!=0){

sum[i]+=8000;

}

if(qm>85&&xx=="Y"){

sum[i]+=1000;

}

if(qm>85&&py>80){

sum[i]+=4000;

}

if(qm>90){

sum[i]+=2000;

}

if(py>80&&gb=="Y"){

sum[i]+=850;

}

jj=max(sum[i],jj);

if(jj==sum[i]&&sum[c]!=sum[i]){

namen=name;

c=i;

}

ans+=sum[i];

}

cout<<namen<<endl;

cout<<jj<<endl;

cout<<ans<<endl;

return 0;

}

注意一下最后的人名就好了,在下两次WA 80 都是因为人名

#1 linxinchang16@2017-12-03 10:30:27
回复 删除
//struct 做法

#include<iostream>

#include<cstring>

using namespace std;

int i,j,k,x,y,z,tot[101];

struct hp

{

string name;

int pingjun;

int banjipingyi;

char ganbu;

char xibu;

int lunwen;

};

int main()

{

int n,max;

hp a[101];

cin>>n;

k=0;

max=0;

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

{

cin>>a[i].name>>a[i].pingjun>>a[i].banjipingyi>>a[i].ganbu>>a[i].xibu>>a[i].lunwen;

if(a[i].pingjun>80&&a[i].lunwen>=1) tot[i]=8000+tot[i];

if(a[i].pingjun>85&&a[i].banjipingyi>80) tot[i]+=4000;

if(a[i].pingjun>90) tot[i]+=2000;

if(a[i].pingjun>85&&a[i].xibu=='Y') tot[i]+=1000;

if(a[i].banjipingyi>80&&a[i].ganbu=='Y') tot[i]+=850;

if(tot[i]>max)

{

max=tot[i];

k=i;

}

}

for(i=1;i<=n;i++) z+=tot[i];

cout<<a[k].name<<endl<<max<<endl<<z<<endl;

return 0;

}

查看更多回复
提交回复