


版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、#in clude<stdio.h>#in clude<stdlib.h>#in clude<stri ng.h>#defi ne stu 30int menu (void);void readche ngji(lo ng xuehao,float che ngji,i nt n);void aversumofche ngji(float xuehao,i nt n);void desortbyche ngji(l ong xuehao,float che ngji,i nt n); void assortbyxuehao(l ong xuehao,floa
2、t che ngji,i nt n); void searchbyxuehao(l ong xuehao,float che ngji,i nt n); void statistica nalysis(float che ngji,i nt n);void prin tche ngji(l ong xuehao,float che ngji,i nt n);int mai n ()char itemSelected;char mima10;int n ,j=0;float che ngjistu;long xuehaostu;char yaosi="6251"char c;
3、printf("ttt學生成績管理系統n");printf("請輸入密碼:”);ago:j=0;while(c=getch()!=13)putchar('*');mimaj=c;j+;mimaj='0' getchar();if (strcmp(mima,yaosi)=0)goto loop;elseprintf("密碼錯誤,請重新輸入:");prin tf("a");prin tf("a");prin tf("a");goto ago;loop:pri
4、ntf("輸入學生人數 n<%d :",stu);shuru:scan f("%d",&n);if(n> stu)printf("輸入錯誤,請重新輸入:");prin tf("a");prin tf("a");prin tf("a");goto shuru;while (1)/當非零的時候/itemSelected=me nu();顯示菜單,并讀取用戶輸入/switch (itemSelected)case 1: readche ngji(xuehao,c
5、he ngji ,n);break;case 2: aversumofche ngji(che ngji, n);break;case 3:desortbyche ngji(xuehao,che ngji, n);printf("n成績降序排列:n學號t成績n”);prin tche ngji(xuehao,che ngji, n);break;case 4: assortbyxuehao(xuehao,che ngji, n);printf("n學號升序排列:n學號t成績n”);prin tche ngji(xuehao,che ngji, n);break;case 5
6、: searchbyxuehao(xuehao,che ngji, n);break;case 6: statistica nalysis(che ngji, n);break;case 7: prin tche ngji(xuehao,che ngji, n);break;case 0: exit(0);printf("程序結束!");break;default:printf("輸入錯誤! ”);break;return 0;/函數功能:顯示菜單并獲得用戶鍵盤輸入的選項/int menu (void)int itemSelected;printf("n
7、學生成績的管理n");printf("t1.學號成績錄入n");prin tf("t2 計算總分和平均分n");printf("t3.根據成績降序排列n");printf("t4.按照學號升序排列n");printf("t5.按學號查詢 n");printf("t6.統計分析 n");printf("t7.列表記錄 n");printf("t0.退出 n"); printf("請輸入你的選擇:");scan
8、 f("%d", &itemSelected); return itemSelected;輸入n個學生的某門課成績/void readche ngji(lo ng xuehao,float che ngji,i nt n)int i;printf("輸入學生學號,成績:n");for (i=0;i <n ;i+)scan f("%ld%f", &xuehaoi,&chen gjii);計算全班總分和平均分 void aversumofche ngji(float che ngji,i nt n)int i
9、;float sum=0;for(i=0;i< n;i+)sum=sum+che ngjii;printf("總分數=%.0f,平均分=%.2fn",sum,n>0?sum/n:0);/按選擇法將數組chengji的元素按從高到低排序/void desortbyche ngji(l ong xuehao,float che ngji,i nt n)int i,j,k;float templ1;long templ2;for (i=0;i<=n _1;i+)k=i;for(j=i+1;j< n;j+)if(che ngjij>che ngjik)
10、k=j;if (k!=i)tempi仁che ngjik;che ngjik=che ngjii;chengjii=templ1; 交換成績 / templ2=xuehaok;xuehaok=xuehaoi;xuehaoi=templ2; 交換學號 /按選擇法將數組xuehao的元素值按從低到高排序/ void assortbyxuehao(l ong xuehao,float che ngji,i nt n) int i,j,k;float n1;long n2;for (i=0;i<=n _1;i+)k=i;for(j=i+1;j< n;j+)if(xuehaoj<xue
11、haok)k=j;if (k!=i)n 1=che ngjik;che ngjik=che ngjii;chengjii=n1; 交換成績 /n 2=xuehaok;xuehaok=xuehaoi;xuehaoi=n2; 交換學號 /按學號查找學生成績并顯示查找結果/void searchbyxuehao(l ong xuehao,float che ngji,i nt n) long nu mber;int i;printf("輸入你要查詢的學號:”);scan f("%ld", &n umber);for (i=0;i <n ;i+)if(xue
12、haoi=nu mber)prin tf("%ldt%.0fn",xuehaoi,che ngjii); return;printf("n 未查詢到! n");/統計各分數段的學生人數及所占的百分比/void statistica nalysis(float che ngji,i nt n)int i,total=0,t6=0,0,0,0,0,0;for (i=0;i <n ;i+)if(che ngjii>=0&&che ngjii<60)t0+;else if(che ngjii<70)t1+;else if(
13、che ngjii<80)t2+;else if(che ngjii<90)t3+;else if(che ngjii<100)t4+;else if(che ngjii=100)t5+;for(i=0;i<=5;i+)total=total+ti;if(total!=n)printf("成績輸入不在正確的范圍”);return;printf("n分數段t人數t百分比n");for(i=0;i<=5;i+)if(i=0)prin tf("<60t%dt%.2f%n",ti,(float)ti/n*100);else if(i=5)prin tf("%dt%dt%.2f%n",(i+5)*10, ti ,(float)ti/n*100);elseprin t
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 錫礦選礦廠企業文化建設與員工關懷考核試卷
- 聚異氰酸酯共聚物纖維單體應用與市場分析考核試卷
- 玉米淀粉在嬰幼兒食品中的應用與安全性評估考核試卷
- 無創呼吸機使用基本知識
- 電氣一次設計畢業答辯
- 麻醉科安全管理
- 伏立康唑在呼吸科臨床應用
- 門診外科換藥規范與操作要點
- 兒童口腔小衛士
- CP-865569-生命科學試劑-MCE
- 2024年中國軟件行業基準數據 (CSBMK-202410)
- 小學四年級下冊四則混合運算及簡便運算
- 公共政策分析概論 課件 第3章 政策主體、政策客體與政策環境
- 《學前教育教育研習》課程教學大綱
- 2024-2025成都各區初二年級下冊期末數學試卷
- 醫療美容行業美容管理流程標準化解決方案
- 目標探測與識別知到智慧樹章節測試課后答案2024年秋北京航空航天大學
- 【MOOC】世界貿易組織法-上海對外經貿大學 中國大學慕課MOOC答案
- 新《安全生產法》安全培訓
- 【MOOC】油氣地質與勘探-中國石油大學(華東) 中國大學慕課MOOC答案
- 花卉栽培學考試要點
評論
0/150
提交評論