- 问答
- 2017-10-27 20:17:27 @
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct
{
char name[20];
int grade;
int cgrade;
char cadres;
char west;
int paper;
int sum;
}student;
void calculate(student a[],int len)
{
int i;
for(i=0;i<len;i++)
{
if(a[i].grade>80)
{
if(a[i].paper>=1)
a[i].sum+=8000;
if(a[i].grade>85)
{
if(a[i].west=='Y')
a[i].sum+=1000;
if(a[i].cgrade>80)
a[i].sum+=4000;
if(a[i].grade>90)
a[i].sum+=2000;
}
}
if(a[i].cadres=='Y'&&a[i].cgrade>80)
a[i].sum+=850;
}
}
int main(){
int N,i,k,min,summary=0;
scanf("%d",&N);
student s=(student)malloc(sizeof(student)*N);
i=N-1;
while(i>=0)
{
scanf("%s",s[i].name);
scanf("%d",&s[i].grade);
scanf("%d",&s[i].cgrade);
getchar();
scanf("%c",&s[i].cadres);
getchar();
scanf("%c",&s[i].west);
scanf("%d",&s[i].paper);
s[i].sum=0;
i--;
}
calculate(s,N);
min=s[0].sum;
k=0;
for(i=0;i<N;i++)
{
if(min<s[i].sum)
{
min=s[i].sum;
k=i;
}
summary+=s[i].sum;
}
printf("%s\n",s[k].name);
printf("%d\n",s[k].sum);
printf("%d",summary);
return 0;
}