學(xué)生管理系統(tǒng)(鏈表版)_第1頁
學(xué)生管理系統(tǒng)(鏈表版)_第2頁
學(xué)生管理系統(tǒng)(鏈表版)_第3頁
學(xué)生管理系統(tǒng)(鏈表版)_第4頁
學(xué)生管理系統(tǒng)(鏈表版)_第5頁
已閱讀5頁,還剩17頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、實(shí)驗(yàn)題目設(shè)計一個簡單實(shí)用班級成績管理系統(tǒng)實(shí)驗(yàn)時間實(shí)驗(yàn)開始日期:報告提交日期:實(shí)驗(yàn)?zāi)康?、要?010實(shí)驗(yàn)報告2011 學(xué)年第 一 學(xué)期 任課老師:福建工程學(xué)院計算機(jī)與信息科學(xué)系1該實(shí)驗(yàn)的課內(nèi)學(xué)時是 4 個課時。2程序完成后應(yīng)該完成如下基本功能:1)用自定義結(jié)構(gòu)體 typedef struct 設(shè)計該軟件的數(shù)據(jù)結(jié)構(gòu);并計算平均成績和總成績 程序能夠顯示已經(jīng)輸入的指定學(xué)號的學(xué)生成績以及平均成績和總成績。 程序能夠按要求顯示指定分?jǐn)?shù)段的學(xué)生成績以及平均成績和總成績。 能夠統(tǒng)計班級總?cè)藬?shù)、班級平均成績。 能夠增加和刪除指定學(xué)生的成績。 按照指定的要求以及順序(升序或降序)顯示學(xué)生成績以及平均成績和2)用

2、數(shù)組或指針鏈表將所有學(xué)生的數(shù)據(jù)按照學(xué)號順序鏈接起來。3)程序能夠按照學(xué)號順序輸入學(xué)生的三門成績,4)5)6)7)8) 總成績。3在完成上述基本功能的前提下,有能力的同學(xué)可以完成如下加強(qiáng)功能:1)能夠輸入的數(shù)據(jù)長期存儲在文件中, 再次運(yùn)行程序時從文件中讀取數(shù)據(jù), 無須重復(fù)輸入。5)在程序的提示語言清晰明確,界面美觀并且適用。實(shí)驗(yàn)設(shè)計內(nèi)容( 1)實(shí)驗(yàn)設(shè)計的數(shù)據(jù)結(jié)構(gòu)typedef structchar name60;char ID7;float Chinese,Math,English ,sum,average;student;(2)層次圖(3) 各個函數(shù)分析1.主函數(shù)main()Int n;FIL

3、E fp;判斷是否存在 data.txt 這個文件 ,不存在就創(chuàng)建該文件 輸入 n 選擇要進(jìn)行的操作 ,根據(jù) n 的值調(diào)用相應(yīng)的函數(shù) 2. 錄入學(xué)生成績struct student *init (int n)定義變量 ;打開文件 ;While()輸入學(xué)生成績放入變量 p;把 p 里面的內(nèi)容打印到文件上 ;關(guān)掉文件 ;3. 插入學(xué)生成績void insert (struct student *head) 定義變量 ;打開文件 ;While()輸入學(xué)生成績放入變量 pi; 插入到指定學(xué)號后面; 關(guān)閉文件;4. 查看學(xué)生成績void list(struct student *head)定義變量 ;打

4、開文件 ;While()顯示學(xué)生成績 5. 查看指定學(xué)號或成績段學(xué)生成績 void search (struct student *head) 定義變量; 打開文件;1. 按學(xué)號查找 輸入要查找的學(xué)號;2. 按分?jǐn)?shù)段查找 錄入成績段;While() 顯示學(xué)生成績6. 統(tǒng)計班級總?cè)藬?shù)及班級平均成績 void tongji (struct student *head) 定義變量; 打開文件 While() 累計班級人數(shù),計算班級總成績 ,各科總成績 計算班級平均成績,顯示結(jié)果;7. 刪除指定學(xué)生的成績 struct student *del (struct student *head,int n)

5、 定義變量; 打開文件; 刪除指定學(xué)生的成績; 保存并關(guān)閉文件;7.排序 void sumas(struct student *head) 定義變量; 比較升序排序;void sumdes(struct student *head)定義變量;比較降序排序;(4) 測試數(shù)據(jù)的設(shè)計及預(yù)期結(jié)果1.錄入的學(xué)生信息 :姓名 學(xué)號 英語數(shù)學(xué)語文張三 1 100100100倩倩 2 808080小麗 11 909090李四 12 606060阿香 30 5050502.預(yù)期結(jié)果:(1)刪除李四張三 1 100100100倩倩 2 808080小麗 11 909090阿香 30 505050( 2)添加李四張

6、三 1 100100100倩倩 2 808080小麗 11 909090李四 12 606060阿香 30 505050(3)統(tǒng)計總?cè)藬?shù)和成績總?cè)藬?shù)為: 5班級英語平均成績:76班級數(shù)學(xué)平均成績:76班級語文平均成績:76( 4)查找指定學(xué)生成績查找總分 200300的學(xué)生姓名 學(xué)號 英語數(shù)學(xué)語文總分張三 1 100100100300倩倩 2 808080240小麗 11 909090270(5)按總分降序排序張三 1 100100100300小麗 11 9090902705倩倩2808080240李四12606060180阿香30505050150(4) 程序界面 .主界面 .學(xué)生成績錄入界

7、面 .成績查詢界面 .排序界面 .退出程序的界面(5)流程圖1. 錄入學(xué)生成績2.顯示學(xué)生成績3.插入學(xué)生信息開始4.刪除數(shù)據(jù)5.查看指定學(xué)號或成績段學(xué)生成績開始否調(diào)試過程記錄本次課題除了排序的函數(shù)在調(diào)試的時候有問題外,其他的都沒有問題 .下面主要寫調(diào)試排序時的錯誤實(shí)驗(yàn)結(jié)果記錄以及與預(yù)期結(jié)果比較以及分析排序結(jié)果截圖分析 :排序結(jié)果搜正確 ,而且能按照不同項(xiàng)目排序 .所以該算法基本上沒問題 總結(jié)以及心得體會指導(dǎo)老師評閱意見指導(dǎo)老師: 年 月 日代碼:#include #include #include #include #define Null 0 struct studentint num;c

8、har name20;float chinese,math,english,ave,sum;struct student *next;10void print ()printf(| 1= 創(chuàng)建學(xué)生數(shù)據(jù)printf(| 2= 載入學(xué)生數(shù)據(jù)printf(| 3= 添加學(xué)生數(shù)據(jù)printf(| 4= 查詢學(xué)生數(shù)據(jù)printf(| 5= 刪除學(xué)生數(shù)據(jù)printf(| 6= 統(tǒng)計班級人數(shù)printf(| 7= 排序printf(| 0= 退出學(xué)生管理系統(tǒng)printf(|n);|n);|n);|n);|n);|n);|n);|n);|n); |n);printf(|n);printf( | 歡迎光臨學(xué)生成

9、績管理系統(tǒng)printf( |n);struct student *init (int n)int i;struct student *head,*p,*s;for (i=1;inum); printf姓(名 n); scanf(%s,&p-name);printf語(文 n); scanf(%f,&p-chinese); printf數(shù)( 學(xué) n); scanf(%f,&p-math); printf英( 語 n); scanf(%f,&p-english); p-sum=p-chinese+p-math+p-english; p-ave=p-sum/3;head=p;if (n=1) p-n

10、ext=Null;elseprintf請( 輸入第 %d個學(xué)生信息 :n,i);s=(struct student *)malloc (sizeof(struct student); printf學(xué)(號 n);11scanf(%d,&s-num);printf姓(名 n);scanf(%s,&s-name);printf語(文 n);scanf(%f,&s-chinese);printf數(shù)( 學(xué) n); scanf(%f,&s-math);printf英( 語 n);scanf(%f,&s-english); s-sum=s-chinese+s-math+s-english; s-ave=s-

11、sum/3;p-next=s;p=s;s-next=Null;return head;void insert (struct student *head)struct student *p,*pi;int xuehao;printf 請( 問要在哪個學(xué)生后面插入數(shù)據(jù)(輸入學(xué)號):);scanf(%d,&xuehao);pi=(struct student *)malloc (sizeof(struct student); p=head;printf學(xué)( 號n); scanf(%d,&pi-num);printf姓( 名n);scanf(%s,&pi-name);printf語( 文n);sca

12、nf(%f,&pi-chinese);printf數(shù)( 學(xué)n); scanf(%f,&pi-math);printf英( 語 n);scanf(%f,&pi-english); pi-sum=pi-chinese+pi-math+pi-english; pi-ave=pi-sum/3;if (head=Null)head=pi;pi-next=Null;elsewhile (p-num!=xuehao)&(p-next!=Null)p=p-next;if (p-next!=Null)pi-next=p-next; p-next=pi;else12p-next=pi; pi-next=Null;

13、void search (struct student *head)int no;struct student *p; p=head;int n=0;printf(1按 學(xué)號查找 n); printf(2按 分?jǐn)?shù)段查找 n);scanf(%d,&n);switch(n)case 1:printf請( 輸入要查找同學(xué)的學(xué)號 :); scanf(%d,&no);while(p!=Null) if(p-num=no)printf(學(xué)-生-成- 績表 n);printf(=n); printf(%-5s%-8s%-8s%-8s%-8s%學(xué)-8s號%-,8姓s名n,語 文,數(shù)學(xué),英語,總分,平均分 );

14、printf(=n);printf(%-5d%-8s%-8.1f%-8.1f%-8.1f%-8.1f%-8.1fn,p-num,p-name,p-chinese,p-math,p-english,p-sum,printf(=n); break;p=p-next;break;case 2:float a,b; int choose; char c; for(;)printf(t|n);printf(t|分?jǐn)?shù)段查詢|n)printf(t|n);printf(t|1=按總分成績查詢|n);printf(t|2=按語文成績查詢|n);printf(t|3=按數(shù)學(xué)成績查詢|n);printf(t|4=按

15、英語成績查詢|n);printf(t|0=返回上一級菜單|n);printf(t|n);printf請( 輸入你要執(zhí)行的操作 :);13scanf(%d,&choose); while(getchar()!=n); switch(choose)平均分 );p=p-next;break;case 3:p=head;printf請( 輸入所要查找的分?jǐn)?shù)段 :n);printf請( 輸入第一個分?jǐn)?shù) :n); scanf(%f,&a);printf請( 輸入第二個分?jǐn)?shù) :n); scanf(%f,&b);printf(%-5s%-8s%-8s%-8s%-8s%學(xué)-8s號%-8,姓sn名,語 文 ,數(shù)學(xué)

16、 ,英語 ,總分 ,14case 1:p=head;printf請( 輸入所要查找的分?jǐn)?shù)段 :n);printf請( 輸入第一個分?jǐn)?shù) :n); scanf(%f,&a);printf請( 輸入第二個分?jǐn)?shù) :n); scanf(%f,&b);printf(%-5s%-8s%-8s%-8s%-8s%學(xué)-8s號%-8,姓sn名,語 文 ,數(shù)學(xué) ,英語 ,總分 ,平均分 );while(p!=Null)if (p-sum=a&p-sumnum,p-name,p-chinese,p-math,p-english,p-sum,p-ave); p=p-next;break;case 2:p=head;pri

17、ntf請( 輸入所要查找的分?jǐn)?shù)段 :n);printf請( 輸入第一個分?jǐn)?shù) :n); scanf(%f,&a);printf請( 輸入第二個分?jǐn)?shù) :n); scanf(%f,&b);printf(%-5s%-8s%-8s%-8s%-8s%學(xué)-8s號%-8,姓sn名,語 文 ,數(shù)學(xué) ,英語 ,總分 ,平均分 );while(p!=Null)if (p-chinese=a&p-chinesenum,p-name,p-chinese,p-math,p-english,p-sum,p-ave);while(p!=Null)if (p-math=a&p-mathnum,p-name,p-chinese,

18、p-math,p-english,p-sum,p-ave); p=p-next;break;case 4:p=head;printf請( 輸入所要查找的分?jǐn)?shù)段 :n);printf請( 輸入第一個分?jǐn)?shù) :n); scanf(%f,&a);printf請( 輸入第二個分?jǐn)?shù) :n);scanf(%f,&b); printf(%-5s%-8s%-8s%-8s%-8s%學(xué)-8s號%-8,姓sn名,語 文 ,數(shù)學(xué) ,英語 ,總分 , 平均分 );while(p!=Null)if (p-english=a&p-englishnum,p-name,p-chinese,p-math,p-english,p-s

19、um,p-ave);p=p-next;break;case 0: return ;default: printf(您n的n 輸入有誤 !請重新輸入: nn);break;struct student *del (struct student *head,int n) struct student *p,*q;p=head;if (head=Null)printf沒( 有學(xué)生的資料要刪除 !n); return head;while (p-num!=n&p-next!=Null)q=p; p=p-next;15if (p-num=n)if (p=head)head=p-next;else q-n

20、ext=p-next;free (p);elseprintf找( 不到相應(yīng)的學(xué)生資料 !n); return head;void list(struct student *head) int i=0; struct student *p; p=head; printf(學(xué)-生-成- 績表 n);printf(=n); printf(%-5s%-8s%-8s%-8s%-8s%學(xué)-8s號%-,8姓s名n,語文 ,數(shù) 學(xué) ,英 語 ,總 分 ,平 均分 );printf(=n);while (p!=Null) printf(%-5d%-8s%-8.1f%-8.1f%-8.1f%-8.1f%-8.1f

21、n,p-num,p-name,p-chinese,p-math,p-english,p-sum,pp=p-next; printf(=n);printf(nn);void tongji (struct student *head)int i=0;struct student *p;float chinese1=0,math1=0,english1=0;p=head;while(p!=Null)i=i+1;chinese1=chinese1+p-chinese;math1=math1+p-math;english1=english1+p-english;p=p-next;printf班( 級總?cè)?/p>

22、數(shù)為: %dn,i);printf班( 級語文平均分為: %4.1fn,chinese1/i);printf班( 級數(shù)學(xué)平均分為: %4.1fn,math1/i);printf班( 級英語平均分為: %4.1fn,english1/i); printf(n);16 student *sort(student *head,int choose)student *p1,*p2=head,*pm,*px;student mid;if (!p2) return head; for(p1=p2;p1-next!=NULL;p1=p1-next)pm=p1; for(p2=p1-next;p2!=NULL

23、;p2=p2-next) switch(choose)case 1:if (pm-nump2-num) pm=p2;break;case 2:if (pm-sumsum) pm=p2;break; case 3:if (pm-chinesechinese) pm=p2;break; case 4:if (pm-mathmath) pm=p2;break; case 5:if (pm-englishenglish) pm=p2;break;if (pm!=p1) mid=*pm; *pm=*p1; *p1=mid; px=pm-next; pm-next=p1-next; p1-next=px;

24、printf(排n 序后的成績表為 :n); list(head);return head;student *sort_all(student *head) int choose;for(;)printf(t|n);printf(t|學(xué)生成績統(tǒng)計排序|n);printf(t|n);printf(t|1= 按學(xué)生學(xué)號排序|n);printf(t|2= 按學(xué)生總分排序|n);printf(t|3= 按學(xué)生語文成績排序|n);printf(t|4= 按學(xué)生數(shù)學(xué)成績排序|n);printf(t|5= 按學(xué)生英語成績排序|n);printf(t|0= 返回上一級菜單|n);printf(t|n);pri

25、ntf請( 輸入你要執(zhí)行的操作 :);scanf(%d,&choose); while(getchar()!=n); switch(choose)case 1:head=sort(head,choose);break;17 case 2:head=sort(head,choose);break;case 3:head=sort(head,choose);break;case 4:head=sort(head,choose);break;case 5:head=sort(head,choose);break;case 0:return head;nn);break;default: printf

26、(您n的n 輸入有誤 !請重新輸入: void save(struct student *head)int i,j;FILE *fp; student *p; p=head;char c; /head頭 指針 if(fp=fopen(c:stu_list,wb)=NULL)printf(Cannot open file strike any key exit!); getch();exit(0); while(p)fwrite(p,sizeof(student),1,fp); p=p-next; fclose(fp);struct student* read()int i=0,j;FILE *fp;struct student *p;/ /工作指針 student *last,*hea/d/最; 后一項(xiàng)的指針 he

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論