1 条题解

  • 0
    @ 2021-6-14 23:29:54

    C :

    #include<stdio.h>
    #include<stdlib.h>
    typedef struct
    {
    	char name[21];
    	int x;
    	int y;
    	char ch;
    	char sh;
    	int z;
    }student;
    
    int main(void)
    {
        int N,a[105],n,m;
    	student stu[100];
        long int sum=0;
        char ch,sh;
    	scanf("%ld",&N);
    	for(int i=0;i<N;i++)
    	  a[i]=0;
    
    	for(int i=0;i<N;i++)
    	{
    		scanf("%s",&stu[i].name);
    		scanf("%d%d",&stu[i].x,&stu[i].y);//x为平均成绩,y为班级评议成绩
    		scanf(" %c %c",&stu[i].ch,&stu[i].sh);//ch为学生干部,sh为西部学生
    		scanf(" %d",&stu[i].z);
    		if(stu[i].x>80&&stu[i].z>=1){
    		    a[i]+=8000;
    		}
    		if(stu[i].x>85&&stu[i].y>80){
    		    a[i]+=4000;
    		}
    		if(stu[i].x>90){
    		    a[i]+=2000;
    		}
    		if(stu[i].x>85&&stu[i].sh=='Y'){
    		    a[i]+=1000;
    		}
    		if(stu[i].y>80&&stu[i].ch=='Y'){
    		    a[i]+=850;
    		}
    		sum+=a[i];
    	}
    	n=a[0];
    	m=0;
    	for(int i=1;i<N;i++)
    	{
    	  if(n<a[i])
    	  {
    	      n=a[i];
    	      m=i;
    	  }
    	}
    
    
    	printf("%s\n",stu[m].name);
    
    	printf("%ld\n",n);
    	printf("%ld\n",sum);
    
    	return 0;
    }
    
    

    C++ :

    #include<iostream>
    #include<cstring>
    #include<cstdio>
    using namespace std;
    struct stu
    {
    	char name[21],gb,xb;
    	int qm,bj,lw;
    	
    }que[100];
    int main()
    {
    	int n,count1=0,count[101];
    	memset(count,0,sizeof(count));
    	cin>>n;
    	for(int i=0;i<n;i++)
    	{
    		cin>>que[i].name>>que[i].qm>>que[i].bj>>que[i].gb>>que[i].xb>>que[i].lw;
    		if(que[i].qm>80&&que[i].lw>=1)
    		{
    			count1+=8000;
    			count[i]+=8000;
    		}
    		if(que[i].qm>85&&que[i].bj>80)
    		{
    			count1+=4000;
    			count[i]+=4000;
    		}
    		if(que[i].qm>90)
    		{
    			count1+=2000;
    			count[i]+=2000;
    		}
    		if(que[i].qm>85&&que[i].xb=='Y')
    		{
    			count1+=1000;
    			count[i]+=1000;
    		}
    		if(que[i].bj>80&&que[i].gb=='Y')
    		{
    			count1+=850;
    			count[i]+=850;
    		}
    	}
    	int max=0,l=0;
    	for(int i=0;i<n;i++)
    	{
    		if(count[i]>max)
    		{
    			max=count[i];
    			l=i;
    		}
    	}
    	cout<<que[l].name<<endl<<count[l]<<endl;
    	printf("%d\n",count1);
    	return 0;
    	
    }
    

    Pascal :

    var
       m,n,i,j,k,t,p,max,q:longint;
       code:integer;
       st:string;
       name,s:array[0..100]of string;
       a:array[0..1000,0..10]of longint;
    begin
     readln(n);
     m:=0;
     q:=1;
    for i:=1 to n do
     begin
      readln(s[i]);
      for j:=1 to length(s[i]) do if (s[i,j] = ' ') then break;
      name[i]:=copy(s[i],1,j-1);
      delete(s[i],1,j);
      for j:= 1 to length(s[i]) do if (s[i,j]= ' ') then break;
      st:=copy(s[i],1,j-1);
      val(st,a[i,1],code);
      delete(s[i],1,j);
      for j:=1 to length(s[i]) do if (s[i,j]= ' ') then break;
      st:=copy(s[i],1,j-1);
      val(st,a[i,2],code);
      delete(s[i],1,j);
      for j:=1 to length(s[i]) do if (s[i,j]=' ') then break;
      st:=copy(s[i],1,j-1);
      if (st = 'Y') then a[i,3] := 1 else a[i,3]:=0;
      delete(s[i],1,j);
      for j:=1 to length(s[i]) do if (s[i,j]=' ') then break;
      st := copy(s[i],1,j-1);
      if (st ='Y') then a[i,4]:=1 else a[i,4]:=0;
      delete(s[i],1,j);
      j:=length(s[i]);
      st:=copy(s[i],1,j);
      val(st,a[i,5],code);
      delete(s[i],1,j);
      if (a[i,1]>80)and(a[i,5]>0) then a[i,6]:=a[i,6]+8000;
      if (a[i,1]>85)and(a[i,2]>80) then a[i,6]:=a[i,6]+4000;
      if (a[i,1]>90)then a[i,6]:=a[i,6]+2000;
      if (a[i,1]>85)and(a[i,4]=1) then a[i,6]:=a[i,6]+1000;
      if (a[i,2]>80)and(a[i,3]=1) then a[i,6]:=a[i,6]+850;
      m:=m+a[i,6];
      if (a[i,6]>max) then
       begin
        max:=a[i,6];
        q:=i;
       end;
    end;
     writeln(name[q]);
     writeln(max);
     writeln(m);
    end.
    
    • 1

    信息

    ID
    242
    时间
    1000ms
    内存
    125MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者