期末考試之排名次

來源:互聯網
上載者:User

標籤:include   clu   個數   不能   input   --   資料   BMI   根據   

期末考試之排名次Time Limit: 1000 ms Memory Limit: 65536 KiBSubmit Statistic DiscussProblem Description期末考試結束了,童鞋們的成績也出來的了,可是為了排名次可忙壞了老師,因為學生太多了。這時,老師把這個任務交給了你,希望你能幫老師完成。作為IT人,你當然不能用笨笨的人工方法了,編程解決才是好辦法。共有三門課,語文、數學和英語,要求根據學生的各科成績計算出其總成績,並根據總成績從高到低排序。Input第一行一個整數N(N<=100),代表學生的人數。接下來的N行資料,每行有三個整數,C,M,E分別代表一個學生語文、數學和英語的成績。Output一共N行,每行一個數,從大到小,分別代表各個學生的總成績。Sample Input370 80 9059 59 59100 100 100Sample Output300240177。

 

 1 #include<stdio.h> 2 struct b 3 { 4     int shuwen; 5     int shuxue; 6     int yingyu; 7     int zong; 8 } student[100],t;//定義student結構體 9 int main()10 {11     int a,i,j,N;12     while (scanf("%d",&N)!=EOF)13     {14         for (i = N; i > 0; i--)15         {16 scanf("%d%d%d", &student[i].shuwen, &student[i].shuxue, &student[i].yingyu);17 student[i].zong = student[i].shuwen + student[i].shuxue + student[i].yingyu;18 19         }20         for (i = 1; i <= N - 1; i++){//由大到小排序21 for (j = i + 1; j <= N; j++)22         if (student[i].zong<student[j].zong)23         {24             t = student[i];25             student[i] = student[j];26             student[j] = t;27         }28         }//由大到小排序29         30         for (i = 1; i <= N; i++)31         {32             printf("%d\n", student[i].zong);33         }34             return EOF;35     }36     return 0;37 }

 

 

  


  


 

期末考試之排名次

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.