結構體統計學產生績

來源:互聯網
上載者:User
#include <stdio.h>struct student{              int eng;  //英語成績       int c;    //C語言成績       int china;  //語文成績       int math;   //數學成績 }; int main(void){    struct student stu[3];    int i;    int max[4], min[4], sum[4];         for(i = 0; i < 3; i++)    {          printf("第%d個學產生績錄入:\n", i + 1);          printf("英文成績\n");          scanf("%d", &stu[i].eng);           printf("C語言成績\n");          scanf("%d", &stu[i].c);           printf("語文成績\n");          scanf("%d", &stu[i].china);           printf("數學成績\n");          scanf("%d", &stu[i].math);           printf("\n");     }         max[0] = stu[0].eng;   //max[0]儲存最大英語成績     min[0] = stu[0].eng;   //min[0]儲存最小英語成績     max[1] = stu[0].c;   //max[1]儲存最大C成績     min[1] = stu[0].c;   //min[1]儲存最小C成績     max[2] = stu[0].china;   //max[2]儲存最大語文成績     min[2] = stu[0].china;   //min[2]儲存最小語文成績     max[3] = stu[0].math;   //max[3]儲存最大數學成績     min[3] = stu[0].math;   //min[3]儲存最小數學成績         sum[0] =  stu[0].eng;   //sum[0]儲存英語總成績     sum[1] =  stu[0].c;   //sum[1]儲存c總成績     sum[2] =  stu[0].china;   //sum[2]儲存語文總成績     sum[3] =  stu[0].math;   //sum[3]儲存數學總成績               for(i = 1; i < 3; i++)    {          if(max[0] < stu[i].eng)                     max[0] =  stu[i].eng;           if(min[0] > stu[i].eng)                     min[0] =  stu[i].eng;                               if(max[1] < stu[i].c)                     max[1] =  stu[i].c;           if(min[1] > stu[i].c)                     min[1] =  stu[i].c;                               if(max[2] < stu[i].china)                     max[2] =  stu[i].china;           if(min[2] > stu[i].china)                     min[2] =  stu[i].china;                               if(max[3] < stu[i].math)                     max[3] =  stu[i].math;           if(min[3] > stu[i].math)                     min[3] =  stu[i].math;                                  sum[0] += stu[i].eng;            sum[1] += stu[i].c;           sum[2] += stu[i].china;           sum[3] += stu[i].math;         }         printf("英語最高成績為:%d\n", max[0]);     printf("英語最低成績為:%d\n", min[0]);     printf("英語最高成績為:%f\n", sum[0]/3.0);         printf("C最高成績為:%d\n", max[1]);     printf("C最低成績為:%d\n", min[1]);     printf("C最高成績為:%f\n", sum[1]/3.0);         printf("語文最高成績為:%d\n", max[2]);     printf("語文最低成績為:%d\n", min[2]);     printf("語文最高成績為:%f\n", sum[2]/3.0);         printf("數學最高成績為:%d\n", max[3]);     printf("數學最低成績為:%d\n", min[3]);     printf("數學最高成績為:%f\n", sum[3]/3.0);                 return 0; } 
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.