




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、精選優(yōu)質文檔-傾情為你奉上# include # include stdlib.h # include string.h#include struct student *Read();void save(struct student *head);void sinput(struct student *p);struct student *input();void paixu_num(struct student *head);struct student *insert();struct student *alter();struct student *del();void find_num
2、(struct student *phead);void find_name(struct student *phead);void output();void min_student(struct student *phead);void max_student(struct student *phead);void ave_student(struct student *phead);void every_student(struct student *phead);void score_paixu(struct student *head);void help();void tj_men
3、u(struct student *head);void find_menu(struct student *head);void menu();struct student/定義學生信息結構數組,用于學生信息輸入 char number13;char name13;char sex4;char adds15;char phone14; char qq14;float chinese,math,english,txhp,pinde,teacher;int zcmc,ksmc;double ave,zc;struct student *next;#define Len sizeof(struct
4、 student)int len; /鏈表長度int a=0,b=0,c=0,d=0,e=0;/用來存放成績各階的人數char stu10;struct student *Read() /讀取數據文件保存到鏈表中,返回指向此鏈表頭指針struct student *head=NULL;struct student *p1, *p2;FILE *fp;cout請輸入你要打開的文件(.dat)stu;if(fp=fopen(stu,rb+)=NULL)cout打開文件出錯!endl;exit(0);while(!feof(fp) if( (p1=(struct student*)malloc(Le
5、n)=NULL )cout內存申請出錯next=p1;p2=p1;fclose(fp);return head;void save(struct student *head)/數據存盤FILE *fp;struct student *p;p=head;cout請輸入你要存進去的文件(.dat)stu;if(fp = fopen(stu, wb)=NULL)cout無法打開文件!endl;system(pause);menu();while(p) if(fwrite(p,Len,1,fp)!=1)cout寫入數據出錯next;cout數據存入成功!請按任意鍵繼續(xù)!endl;getchar();f
6、close(fp);/單次輸入void sinput(struct student *p)cout請輸入學號:p-number;cout請輸入姓名: p-name;cout請輸入性別: p-sex;cout請輸入家庭住址: p-adds;cout請輸入聯系電話: p-phone;cout請輸入qq: p-qq;cout請輸入語文成績:p-chinese;if(p-chinese100|p-chinese0)cout成績輸入不符合規(guī)定,請重新輸入:p-chinese;cout請輸入數學成績:p-math;if(p-math100|p-math0)cout成績輸入不符合規(guī)定,請重新輸入:p-mat
7、h;cout請輸入英語成績:p-english;if(p-english100|p-english0)cout成績輸入不符合規(guī)定,請重新輸入:p-english;cout請輸入同學互評分:p-txhp;if(p-txhp100|p-txhp0)cout成績輸入不符合規(guī)定,請重新輸入:p-txhp;cout請輸入品德成績:p-pinde;if(p-pinde100|p-pinde0)cout成績輸入不符合規(guī)定,請重新輸入:p-pinde;cout請輸入任課教師評分:p-teacher;if(p-teacher100|p-teacher0)cout成績輸入不符合規(guī)定,請重新輸入:p-teacher
8、;p-ave=(p-chinese+p-math+p-english)/3.0;p-zc=(p-ave*0.6+p-txhp*0.1+p-pinde*0.2+p-teacher*0.1);coutendl;coutendl;cout你剛輸入的信息為:endl;couttt學號:numberendl;couttt姓名:nameendl;couttt性別:sexendl;couttt家庭住址:addsendl;couttt聯系電話:phoneendl;coutttQQ號:qqendl;couttt語文成績:chineseendl;couttt數學成績:mathendl;couttt英語成績:eng
9、lishendl;couttt品德成績:pindeendl;couttt教師評分:teacherendl;coutendl;return;/學生成績錄入函數struct student *input()struct student *head=NULL,*p1,*p2;/輸入p1,p2鏈表最后節(jié)點char ch=y;len=1; p2=p1=(struct student *)malloc(sizeof(struct student);cout請輸入第len個學生的信息:endl;sinput(p1);coutendl;cout按n退出或按任意鍵繼續(xù)ch;while(1)if(len=1)/作
10、為頭結點 head=p1;else p2-next=p1;p2=p1;if(ch=N|ch=n)break;p1=(struct student *)malloc(sizeof(struct student);system(cls);len+;cout請輸入第len個學生的信息:endl;sinput(p1);coutendl;cout按n退出或按任意鍵繼續(xù)ch;p2-next=NULL;paixu_num(head);cout輸入學生信息完成!請按任意鍵返回主菜單!endl;getchar();return head;/學號排序void paixu_num(struct student *h
11、ead) struct student t,*r,*p,*q;/t交換p、q,r頭結點 r=head; if(r=NULL) cout學生信息不存在,請先輸入學生信息!next;while(q) if(strcmp(q-number,p-number)0) /qnumber);strcpy(,q-name); strcpy(t.sex,q-sex); strcpy(t.adds,q-adds); strcpy(t.phone,q-phone); strcpy(t.qq,q-qq); t.chinese=q-chinese; t.math=q-math; t.english=q-en
12、glish; t.txhp=q-txhp; t.pinde=q-pinde; t.teacher=q-teacher;strcpy(q-number,p-number);strcpy(q-name,p-name); strcpy(q-sex,p-sex); strcpy(q-adds,p-adds); strcpy(q-phone,p-phone); strcpy(q-qq,p-qq); q-chinese=p-chinese; q-math=p-math; q-english=p-english; q-txhp=p-txhp; q-pinde=p-pinde; q-teacher=p-tea
13、cher;strcpy(p-number,t.number);strcpy(p-name,); strcpy(p-sex,t.sex); strcpy(p-adds,t.adds); strcpy(p-phone,t.phone); strcpy(p-qq,t.qq); p-chinese=t.chinese; p-math=t.math; p-english=t.english; p-txhp=t.txhp; p-pinde=t.pinde; p-teacher=t.teacher; q=q-next; r=r-next; /插入函數struct student *insert(
14、)struct student *p,*p1,*head;head=Read();p1=head;p=(struct student *)malloc(sizeof(struct student);char num14,ch;cout請輸入你要插入的前一個學生的學號:num;while(p1)if(!strcmp(p1-number,num)sinput(p);p-next=p1-next;p1-next=p;len+;elsep1=p1-next;cout按n退出或按任意鍵繼續(xù)ch;if(ch=N|ch=n)break;cout學生信息插入成功!請按任意鍵返回!endl;getchar();
15、return head;/修改學生信息struct student *alter()char temp13; struct student *p,*head;head=Read();p=head;couttemp;while(p)if(!strcmp(p-number,temp)sinput(p);p=p-next;coutendl;cout學生信息修改成功!請按任意鍵返回!endl;coutendl;system(pause);return head;/刪除學生信息struct student *del() char temp13;int m=0;struct student *p1,*p,
16、*head;/p1刪除head=Read();p1=p=head;cout請輸入你要刪除學生的學號:temp;while(p)if(strcmp(p1-number,temp)=0)if(p1=head)/刪除的頭結點head=p1-next;else p-next=p1-next;len-;m=1;cout學生信息刪除成功!請按任意鍵返回主菜單.next;if(!m)cout查找不到這個信息!endl;return head;void find_num(struct student *head)/按學號查找 struct student *p=head;char temp9;int m =
17、0;cout請輸入要查找的學生的學號temp;while(p!=NULL) if(strcmp(p-number,temp) = 0) cout該學生的具體信息為:endl;coutendl;coutendl;couttt學號:numberendl;couttt姓名:nameendl;couttt性別:sexendl;couttt家庭住址:addsendl;couttt聯系電話:phoneendl;coutttQQ號:qqendl;couttt語文成績:chineseendl;couttt數學成績mathendl;couttt英語成績englishendl;couttt平均成績aveendl;
18、couttt品德成績pindeendl;couttt老師評分teacherendl;couttt綜合成績zcendl;score_paixu(head);couttt考試名次ksmcendl;couttt綜測名次zcmcendl;coutendl;coutnext;/繼續(xù)向下尋找if(!m)cout查找不到這個學號的信息!endl;cout按任意鍵返回主菜單endl;getchar();return ;void find_name(struct student *head)/按姓名查找 struct student *p= head;char temp9;int m = 0;cout請輸入要查
19、找的學生的姓名temp;while(p)if(strcmp(p-name,temp) = 0)cout該學生的具體信息為:endl;coutendl;coutendl;cout學號:numberendl;couttt姓名:nameendl;couttt性別:sexendl;couttt家庭住址:addsendl;couttt聯系電話:phoneendl;coutttQQ號:qqendl;couttt語文成績:chineseendl;couttt數學成績mathendl;couttt英語成績englishendl;couttt平均成績aveendl;couttt品德成績pindeendl;cou
20、ttt老師評分teacherendl;couttt綜合成績zcendl;score_paixu(head);couttt考試名次ksmcendl;couttt綜測名次zcmcendl;coutendl;coutnext;if(!m)cout查找不到這個學號的信息!endl;cout按任意鍵返回主菜單endl;getchar();return ;void output()struct student *p,*head;head=Read();p=head;int i=1; while(p) coutendl;couttt學號:numberendl;couttt姓名:nameendl;couttt
21、性別:sexendl;couttt家庭住址:addsendl;couttt聯系電話:phoneendl;coutttQQ號:qqendl;couttt語文成績:chineseendl;couttt數學成績:mathendl;couttt英語成績:englishendl;couttt品德成績:pindeendl;couttt老師評分:teacherendl;couttt平均成績:aveendl;couttt綜合成績:zcendl;score_paixu(head);couttt考試名次ksmcendl;couttt綜合測評名次zcmcnext;i+; coutendl;coutendl;cout
22、請按任意鍵返回主菜單chinesec2) c2=p-chinese;if(p-mathm2) m2=p-math;if(p-englishe2) e2=p-english;if(p-chinese+p-math+p-english)s2) s2=(p-chinese+p-math+p-english);if(p-pindep2) p2=p-pinde;if(p-txhpstu2) stu2=p-txhp;if(p-teachert2) t2=p-teacher;if(p-avea2)a2=p-ave;if(p-zczc2)zc2=p-zc;p=p-next;coutendl;couttt語文最
23、高分:c2endl;couttt數學最高分:m2endl;couttt英語最高分:e2endl;couttt總成績最高分:s2endl;couttt品德最高分:p2endl;couttt同學互評分最高:stu2endl;couttt教師評分最高:t2endl;couttt平均分最高:a2endl;couttt綜測最高分:zc2endl;coutendl;coutendl;cout請按任意鍵返回.chinesechinese;if(p-mathmath;if(p-englishenglish;if(p-chinese+p-math+p-english)chinese+p-math+p-engli
24、sh);if(p-pindepinde;if(p-txhptxhp;if(p-teacherteacher;if(p-aveave;if(p-zczc; p=p-next;coutendl;couttt語文最低分:c1endl;couttt數學最低分:m1endl;couttt英語最低分:e1endl;couttt總成績最低分:s1endl;couttt品德最低分:p1endl;couttt同學互評分最低分:stu1endl;couttt教師評分最低分:t1endl;couttt平均分最低分:a1endl;couttt綜測最低分:zc1endl;coutendl;coutendl;cout請按
25、任意鍵返回.chinese; m_sum+=p-math; e_sum+=p-english;p_sum+=p-pinde;stu_sum+=p-txhp;t_sum+=p-teacher;zc_sum+=p-zc;p=p-next;c_ave=c_sum/len;m_ave=m_sum/len;e_ave=e_sum/len;all_ave=(c_ave+m_ave+e_ave)/3;p_ave=p_sum/len;stu_ave=stu_sum/len;t_ave=t_sum/len;zc_ave=zc_sum/len;coutttendl;couttt語文平均分為:c_aveendl;c
26、outtt數學平均分為:m_aveendl;couttt英語平均分為:e_aveendl;couttt總成績平均為:all_aveendl;couttt品德平均分為:p_aveendl;couttt同學互評平均分為:stu_aveendl;couttt教師評分平均分為:t_aveendl;couttt綜測平均分為:zc_aveendl;coutttendl;coutendl;cout請按任意鍵返回.ave/10)case 10:case 9:a+;break;case 8:b+;break;case 7:c+;break;case 6:d+;break;default:e+;p=p-next;
27、coutendl;cout平均成績在90分以上的有:aendl;cout平均成績在80分以上的有:bendl;cout平均成績在70分以上的有:cendl;cout平均成績在60分以上的有:dendl;cout平均成績在60分以下的有:echinese/10)case 10:case 9:a+;break;case 8:b+;break;case 7:c+;break;case 6:d+;break;default:e+;p=p-next;coutendl;cout語文成績在90分以上的有:aendl;cout語文成績在80分以上的有:bendl;cout語文成績在70分以上的有:cendl;
28、cout語文成績在60分以上的有:dendl;cout語文成績在60分以下的有:emath/10)case 10:case 9:a+;break;case 8:b+;break;case 7:c+;break;case 6:d+;break;default:e+;p=p-next;coutendl;cout數學成績在90分以上的有:aendl;cout數學成績在80分以上的有:bendl;cout數學成績在70分以上的有:cendl;cout數學成績在60分以上的有:dendl;cout數學成績在60分以下的有:eenglish/10)case 10:case 9:a+;break;case
29、8:b+;break;case 7:c+;break;case 6:d+;break;default:e+;p=p-next;coutendl;cout英語成績在90分以上的有:aendl;cout英語成績在80分以上的有:bendl;cout英語成績在70分以上的有:cendl;cout英語成績在60分以上的有:dendl;cout英語成績在60分以下的有:epinde/10)case 10:case 9:a+;break;case 8:b+;break;case 7:c+;break;case 6:d+;break;default:e+;p=p-next;coutendl;cout品德成績
30、在90分以上的有:aendl;cout品德成績在80分以上的有:bendl;cout品德成績在70分以上的有:cendl;cout品德成績在60分以上的有:dendl;cout品德成績在60分以下的有:etxhp/10)case 10:case 9:a+;break;case 8:b+;break;case 7:c+;break;case 6:d+;break;default:e+;p=p-next;coutendl;cout同學互評在90分以上的有:aendl;cout同學互評在80分以上的有:bendl;cout同學互評在70分以上的有:cendl;cout同學互評在60分以上的有:den
31、dl;cout同學互評在60分以下的有:eteacher/10)case 10:case 9:a+;break;case 8:b+;break;case 7:c+;break;case 6:d+;break;default:e+;p=p-next;coutendl;cout教師評分在90分以上的有:aendl;cout教師評分在80分以上的有:bendl;cout教師評分在70分以上的有:cendl;cout教師評分在60分以上的有:dendl;cout教師評分在60分以下的有:ezc/10)case 10:case 9:a+;break;case 8:b+;break;case 7:c+;b
32、reak;case 6:d+;break;default:e+;p=p-next;coutendl;cout綜測成績在90分以上的有:aendl;cout綜測成績在80分以上的有:bendl;cout綜測成績在70分以上的有:cendl;cout綜測成績在60分以上的有:dendl;cout綜測成績在60分以下的有:eendl;coutendl;cout請按任意鍵退出.next;double *ave1=new doublen;double *zc1=new doublen;for(int i=0;iave;zc1i=p1-zc;p1=p1-next; for(i=0;in;i+)/冒泡排序
33、for(int j=0;jn;j+) if(ave1jave1j+1) double ave11=ave1j;ave1j=ave1j+1; ave1j+1=ave11; if(zc1jzc1j+1) double zc11=zc1j;zc1j=zc1j+1; zc1j+1=zc11; while(r)for(i=0;iave) r-ksmc=i+1;if(zc1i=r-zc) r-zcmc=i+1;r=r-next;cout排名完成!請按任意鍵返回主菜單的瀏覽學生信息查看!(如果是瀏覽學生信息則按任意鍵得到名次!)endl;delete ave1;delete zc1;getchar();re
34、turn;/幫助void help()system (cls);/清屏cout *歡迎使用學生綜合測評系統(tǒng)* endl;coutendl;cout本系統(tǒng)可以存儲學生的基本信息和數據信息,所有信息按學號以小到大的順序存入文件。endl;cout基本信息包括:學號、姓名、性別、家庭住址、聯系電話、qqendl;cout數據信息包括:語文、數學、外語三門單科成績、考試平均成績、考試名次、同學互評分、品德成績、任課教師評分、綜合測評分、綜合測評名次endl;cout綜合測評分(考試平均成績)*0.6+(同學互評分)*0.1+品德成績*0.1+任課老師評分*0.2。endl;cout考試成績(語文+數學+外語)/3 endl;coutendl;cout該菜單分為三個菜單,一個主菜單,兩個子菜單。endl;cout主菜單提供基本信息操作,子菜單分別提供學生信息查找功能、學生數據統(tǒng)計功能。endl
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 配件買賣合同
- 湖北省十堰市2024-2025學年高二上學期1月期末地理試題 含解析
- 日常辦公事務處理文書詳案
- 融資借款合同協(xié)議書
- 數據傳輸效率評估表
- 產品分銷合同協(xié)議規(guī)范書
- 中學生科普知識解讀征文
- 電商平臺在線客服機器人技術支持協(xié)議
- 《現代酒店管理基礎》(第二版)課件 任務9 酒店集團化管理
- 幼兒啟蒙成語故事解讀
- 2024年3、6、9月青少年軟件編程Python等級考試一級真題(全3套 含答案)
- 部編版小學語文三年級語文下冊第三單元集體備課教材分析解讀
- 2023年河北省安全生產舉報和獎勵答試題及答案
- 2021年中國遠洋海運集團有限公司招聘筆試試題及答案解析
- 《大學物理學》課程教學大綱
- 勵志班會你想成為什么樣人
- ISOTS-9002:2022質量管理體系ISO9001:2022-應用指南
- 《帶狀皰疹治療學》牛德興教授專業(yè)研究治療病毒性皰疹50年心血
- 戴氏無線電遙控飛機教程
- 巴黎盧浮宮介紹PPT模板課件
- 蒂森克虜伯電梯曳引輪鋼絲繩安裝布置
評論
0/150
提交評論