c言語(yǔ)課程設(shè)計(jì)門生學(xué)籍管理系統(tǒng)_第1頁(yè)
c言語(yǔ)課程設(shè)計(jì)門生學(xué)籍管理系統(tǒng)_第2頁(yè)
c言語(yǔ)課程設(shè)計(jì)門生學(xué)籍管理系統(tǒng)_第3頁(yè)
已閱讀5頁(yè),還剩2頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

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學(xué)生成績(jī)管理系統(tǒng)n");printf("請(qǐng)輸入密碼:”);ago:j=0;while(c=getch()!=13)putchar('*');mimaj=c;j+;mimaj='0' getchar();if (strcmp(mima,yaosi)=0)goto loop;elseprintf("密碼錯(cuò)誤,請(qǐng)重新輸入:");prin tf("a");prin tf("a");prin tf("a");goto ago;loop:pri

4、ntf("輸入學(xué)生人數(shù) n<%d :",stu);shuru:scan f("%d",&n);if(n> stu)printf("輸入錯(cuò)誤,請(qǐng)重新輸入:");prin tf("a");prin tf("a");prin tf("a");goto shuru;while (1)/當(dāng)非零的時(shí)候/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成績(jī)降序排列:n學(xué)號(hào)t成績(jī)n”);prin tche ngji(xuehao,che ngji, n);break;case 4: assortbyxuehao(xuehao,che ngji, n);printf("n學(xué)號(hào)升序排列:n學(xué)號(hào)t成績(jī)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("程序結(jié)束!");break;default:printf("輸入錯(cuò)誤! ”);break;return 0;/函數(shù)功能:顯示菜單并獲得用戶鍵盤輸入的選項(xiàng)/int menu (void)int itemSelected;printf("n

7、學(xué)生成績(jī)的管理n");printf("t1.學(xué)號(hào)成績(jī)錄入n");prin tf("t2 計(jì)算總分和平均分n");printf("t3.根據(jù)成績(jī)降序排列n");printf("t4.按照學(xué)號(hào)升序排列n");printf("t5.按學(xué)號(hào)查詢 n");printf("t6.統(tǒng)計(jì)分析 n");printf("t7.列表記錄 n");printf("t0.退出 n"); printf("請(qǐng)輸入你的選擇:");scan

8、 f("%d", &itemSelected); return itemSelected;輸入n個(gè)學(xué)生的某門課成績(jī)/void readche ngji(lo ng xuehao,float che ngji,i nt n)int i;printf("輸入學(xué)生學(xué)號(hào),成績(jī):n");for (i=0;i <n ;i+)scan f("%ld%f", &xuehaoi,&chen gjii);計(jì)算全班總分和平均分 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("總分?jǐn)?shù)=%.0f,平均分=%.2fn",sum,n>0?sum/n:0);/按選擇法將數(shù)組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; 交換成績(jī) / templ2=xuehaok;xuehaok=xuehaoi;xuehaoi=templ2; 交換學(xué)號(hào) /按選擇法將數(shù)組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; 交換成績(jī) /n 2=xuehaok;xuehaok=xuehaoi;xuehaoi=n2; 交換學(xué)號(hào) /按學(xué)號(hào)查找學(xué)生成績(jī)并顯示查找結(jié)果/void searchbyxuehao(l ong xuehao,float che ngji,i nt n) long nu mber;int i;printf("輸入你要查詢的學(xué)號(hào):”);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");/統(tǒng)計(jì)各分?jǐn)?shù)段的學(xué)生人數(shù)及所占的百分比/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("成績(jī)輸入不在正確的范圍”);return;printf("n分?jǐn)?shù)段t人數(shù)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等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論