zoukankan      html  css  js  c++  java
  • 课堂作业补充

    #include<stdio.h>
    struct Student
    {
        int num;
        char name[20];
        int Cscore;
        int Escore;
        int Mscore;
        int aver;
    };
    
    
    
    
    
    int main()
    {
        void averr(struct Student stu[]);
        void input (struct Student stu[]);
        struct Student max(struct Student stu[]);
        void print(struct Student stud);
        struct Student stu[5];
        struct Student *p;
        p=stu;
        input(p);
        print(max(p));
        averr(p);
        return 0;
     } 
     
     
     void input (struct Student stu[])
     {
          void averr(int a);
         int i;
         
         printf("请输入学生信息:
    ");
         for(i=0;i<5;i++)
         {
             scanf("%d %s %d %d %d",&stu[i].num,stu[i].name,&stu[i].Cscore,&stu[i].Escore,&stu[i].Mscore);
             stu[i].aver=(stu[i].Cscore+stu[i].Escore+stu[i].Mscore)/3;
             
             
             
         }
     }
     
     
     
     
     void averr(struct Student stu[])
     {
         int a,t,f;
         f=0;
         for(t=0;t<5;t++)
         f=f+stu[t].Cscore;
         printf("Cscore总平均成绩=%d
    ",f/5);
         f=0;
         for(t=0;t<5;t++)
         f=f+stu[t].Escore;
         printf("Escore总平均成绩=%d
    ",f/5);
         f=0;
         for(t=0;t<5;t++)
         f=f+stu[t].Mscore;
         printf("Mscore总平均成绩=%d
    ",f/5);
     }
     
     struct Student max(struct Student stu[])
     {
         int i,m=0;
         for(i=0;i<5;i++)
         if(stu[i].aver>stu[m].aver)
         m=i;
         return stu[m];
         
     }
     
     void print(struct Student stud)
     {
         printf("
    成绩最高的学生是:
    ");
         printf("学号:%d
    姓名:%s
    三门课成绩:%d,%d,%d
    平均成绩:%d
    ",stud.num,stud.name,stud.Cscore,stud.Escore,stud.Mscore,stud.aver);
         
         
     }
     
    请输入学生信息:
    123 huk 1 2 3
    456 jgy 4 5 6
    789 kkh 7 8 9
    147 liy 1 4 7
    258 mhg 2 5 8
    
    成绩最高的学生是:
    学号:789
    姓名:kkh
    三门课成绩:7,8,9
    平均成绩:8
    Cscore总平均成绩=3
    Escore总平均成绩=4
    Mscore总平均成绩=6
    
    --------------------------------
    Process exited after 46.5 seconds with return value 0
    请按任意键继续. . .
  • 相关阅读:
    MySQL 多会话之间更新数据的小实例
    MySQL Profile
    MySQL Explain
    MySQL 索引
    利用网站上传漏洞使用一句话木马控制服务器
    kali之nmap
    kali之使用sqlmap进行sql注入
    kali之DVWA
    Kali安装nessus
    openvas
  • 原文地址:https://www.cnblogs.com/abtious/p/6696758.html
Copyright © 2011-2022 走看看