瓦力


私信TA

用户名:wang2012jx

访问量:13251

签 名:

三十入门

等  级
排  名 485
经  验 4523
参赛次数 3
文章发表 42
年  龄 0
在职情况 在职
学  校 清华大学
专  业

  自我简介:

解题思路:

注意事项:

参考代码:

#include<stdio.h>
#include<stdlib.h>
typedef struct student
{    
    char id[10];    
    char name[10];    
    int score1;     
    int score2;     
    int score3; 
    int s;   
    struct student *next;
}Stu;
int main()
{    
    int n;    
    scanf("%d",&n);        
    int i,sum1=0,sum2=0,sum3=0;         
    Stu *head,*end,*pnew,*p,*max;    
    head=(Stu*)malloc(sizeof(Stu));    
    head->next=NULL;    
    end=head;    
    for(i=0;i<n;i++)    
    {        
        pnew=(Stu*)malloc(sizeof(Stu));        
        scanf("%s%s%d%d%d",&pnew->id,&pnew->name,&pnew->score1,&pnew->score2,&pnew->score3);       
        pnew->s=pnew->score1+pnew->score2+pnew->score3;
        pnew->next=NULL;        
        end->next=pnew;        
        end=pnew; 
         sum1+=pnew->score1;
         sum2+=pnew->score2;
         sum3+=pnew->score3; 
           
    }    
    max=head;    
    for(p=head->next;p!=NULL;p=p->next)    
    {         
        if(p->s>max->s)
        max=p;
    }
    
    printf("%d %d %d\n",sum1/n,sum2/n,sum3/n);
    printf("%s %s %d %d %d",max->id,max->name,max->score1,max->score2,max->score3);
    return 0;
    free(head);
     free(pnew);
    free(p);
    free(max);
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区