幫人做的一份課程設計

來源:互聯網
上載者:User

/*

 

計算學生C語言期末總成績一、項目簡介某高校現需一個能計算某班學生C語言期末總成績的程式。現C語言成績計算方法如下:總成績分為兩部分,一是理論課成績,令一部分是實驗課成績。其中理論課成績=(筆試考試成績 - 理論課綜合訓練成績扣分)*60%,實驗課成績=(機考成績–上機扣分)*40%,理論課綜合訓練成績扣分0~20。要求計算總成績且按照成績從高到低排列,並能提示是否掛科(60分為界,小於60為未過)。盤檔案輸入,有學號、筆試考試成績、理論課綜合訓練成績扣分、機考成績、上機扣分。並盤檔案輸出,有學號、總成績、掛科情況。二、運行樣本輸入下列五列(第一列是學號、第二列是筆試考試成績、第三列是理論課綜合訓練成績扣分、第四列是機考成績、第五列是上機扣分)03 80 5 60 021 68 4 76 316 81 0 75 009 64 8 64 515 60 5 67 6
*/

/*這是最簡單的,用結構體而非鏈表,傳值直接傳結構體而非結構體指標的程式。update version,看看有沒時間去改這個程式吧
 *這個程式的完工,首先特別鳴謝seed的大力支援,他給我解答了關於結構體傳遞方面的問題。Thanks。
 */
/* * main.c * *  Created on: 2011-6-6 *      Author: icelights */#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>#define TotalStu 5      /*學生總數Total student*/struct Database{/*學號Student No.*/char        sn[80];/*筆試成績Written test score*/double      wts;/*理論課綜合訓練成績扣分    *Comprehensive training course grades possessed*/double      ctcgp;/*機考成績Machine examination results*/double      mer;/*上機扣分Computer possessed*/double      cp;/*總成績Total score*/double      ts;/*掛科與否Hanged division*/int         hd;};/*輸出檔案*/void output(struct Database Stu[]){FILE *fp;int liv_cnt;if((fp=fopen("d://StuDBA.txt","wt+"))== NULL){puts("Couldn't read the file/n");}rewind(fp);for(liv_cnt = 0; liv_cnt < TotalStu; liv_cnt++){fprintf(fp,"%s %lf %d/n" , Stu[liv_cnt].sn,Stu[liv_cnt].ts, Stu[liv_cnt].hd);}if(fclose(fp)){puts("Fail to close the file./n");   }}/*計算成績&判斷掛科*/void cal(struct Database Stu[]){int liv_cnt;for (liv_cnt = 0; liv_cnt < TotalStu; liv_cnt++){Stu[liv_cnt].ts = (Stu[liv_cnt].wts - Stu[liv_cnt].ctcgp) * 0.6+ (Stu[liv_cnt].mer - Stu[liv_cnt].cp) * 0.4; if (Stu[liv_cnt].ts < 60) { Stu[liv_cnt].hd = 0; } else { Stu[liv_cnt].hd = 1; }}output(Stu);}/*接受使用者輸入*/void input(void){struct Database Stu[TotalStu];int liv_cnt;puts("Please enter the Student No. Written test score");puts("Comprehensive training course grades possessed");puts("Machine examination results and Computer possessed");for (liv_cnt = 0; liv_cnt < TotalStu; liv_cnt++){scanf("%s%lf%lf%lf%lf",Stu[liv_cnt].sn, &Stu[liv_cnt].wts, &Stu[liv_cnt].ctcgp,&Stu[liv_cnt].mer, &Stu[liv_cnt].cp);}/*end of for (liv_cnt = 0; liv_cnt < TotalStu; liv_cnt++)*/cal(Stu);}/*主函數*/int main(void){input();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.