统计成绩

发布于 2019-12-17  0 次阅读


结构体

    #include
    #include
    #define st struct student
    #include
    struct student
    {
        int num,score;
        char name[9];
        struct student *next;
    };
    void main()
    {
        st *head=NULL,*p,*q;int n,i,max=0,num;char name[9]={'\0'};
        printf("请输入班级人数:");
        scanf("%d",&n);
            for(i=1;iname,&q->num,&q->score);
                q->next=NULL;
                if(head==NULL)
                    head=q;
                else
                    p->next=q;
                p=q;
            }
            p=head;
            while(p!=NULL)
            {
                if(p->score>max)
                {
                    max=p->score;
                strcpy(name,p->name);
                    num=p->num;
                }
                p=p->next;
            }
            printf("姓名是%s学号是%d成绩是%d\n",name,num,max);
    }

本当の声を響かせてよ