C++学生管理系统代码_第1页
C++学生管理系统代码_第2页
C++学生管理系统代码_第3页
C++学生管理系统代码_第4页
C++学生管理系统代码_第5页
已阅读5页,还剩29页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

#include #include #include #include #include #include usingnamespacestd; constintNAME_NUM=30; structstudent charnameNAME_NUM; floatnum; floatchinaNum; floatenglishNum; floatmathNum; floataverage; floatresult; intpos; student*next; ; voidPrint(student*head); voidInsertFront(student*&head,student*pNew); voidInsertRear(student*&head,student*pNew); student*Find(student*head,char*findStr,chartype); student*Read(); voidWrite(student*head); voidShowList(student*head); intGetLength(student*head); voidDelete(student*&head,char*delStr,intdelNum); voidFindMaxOrMin(student*head,chartype,charmaxOrMin); voidReword(student*pStd); voidSort(student*&head,chartype,charmaxOrMin); voidCount(student*&head); voidDeleteAll(student*&head); boolEnter(chartype); voidSetTitle(boolisLoad); voidAboutMe(); voidChaXun(stringstr,student*head); voidPaiMing(stringstr,student*head); voidShanChu(stringstr,student*&head); voidXianShi(stringstr,student*head); voidXuiGai(stringstr,student*&head); voidZengJia(stringstr,student*&head); intRun(); boolEnter(chartype) ofstreamout(Password.pwd,ios:app); ifstreamin(Password.pwd); strings2; intnum=0; stringzhangHao; stringmiMa; while(!in.eof() insnum; num+; if(num=2) break; if(pare()=0|type=2) if(pare()=0&type!=2) cout你是第一次使用本程序,请设置帐号和密码.endl; else boolisLoad=false; isLoad=Enter(1); if(isLoad=true) cout修改用户.endl; out.close(); out.open(Password.pwd,ios:trunc); else cout你输入的密码错误.endl; cout你不是管理员不能修改密码.endl; returnfalse; couts0; couts1; strings1,s2; for(inti=0;is0.size();i+) s1+=char(int(s0i)+11); for(i=0;is1.size();i+) s2+=char(int(s1i)+11); s0=s1; s1=s2; for(i=0;i=1;i+) outsi; out.close(); strings1,s2; for(inti=0;is0.size();i+) s1+=char(int(s0i)-11); for(i=0;is1.size();i+) s2+=char(int(s1i)-11); coutzhangHao; coutmiMa; if(zhangHpare(s1)=0&miMpare(s2)=0) returntrue; else returnfalse; returnfalse; voidPrint(student*head) student*pHead=head; intnum=strlen(head-name); while(head) if(numname) num=strlen(head-name); head=head-next; head=pHead; coutsetw(num)namesetw(8) numsetw(10)chinaNum setw(10)mathNumsetw(10) englishNumsetw(8)result setw(8)averagesetw(5)posendl; voidShowList(student*head) cout姓名:setw(8)座号:setw(10) 语文分数:setw(10)数学分数: setw(10)英语分数:setw(8)总分数: setw(8)平均分:setw(6)名次:endlnext; coutnext; out.close(); student*Read() ifstreamin(Student.dat); student*head; student*pP; student*pEnd; pP=newstudent; pEnd=head=pP; student*pS=newstudent; memset(pS-name,0,NAME_NUM); in.read(char*)pS,sizeof(student); if(strcmp(pS-name,0)=0) returnNULL; strcpy(pP-name,pS-name); pP-num=pS-num; pP-chinaNum=pS-chinaNum; pP-englishNum=pS-englishNum; pP-mathNum=pS-mathNum; while(!in.eof() in.read(char*)pS,sizeof(student); pEnd-next=pP; pEnd=pP; pP=newstudent; strcpy(pP-name,pS-name); pP-num=pS-num; pP-chinaNum=pS-chinaNum; pP-englishNum=pS-englishNum; pP-mathNum=pS-mathNum; pEnd-next=NULL; deletepP; returnhead; student*Find(student*head,char*findStr,chartype) /*参数说明: type=1按名字查找 type=2按座号查找 type=3按语文查找 type=4按数学查找 type=5按英语查找 type=6按总分查找 type=7按平均分查找 type=8按排名查找/没有实现 */ boolisFind=false; student*firstStd=NULL; cout姓名:setw(8)座号:setw(10) 语文分数:setw(10)数学分数: setw(10)英语分数:setw(8)总分数: setw(8)平均分:setw(5)名次:endlname,findStr)=0) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) returnfirstStd; elseif(type=2) if(int(head-num)=int(atof(findStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) returnfirstStd; elseif(type=3) if(int(head-chinaNum)=int(atof(findStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) returnfirstStd; elseif(type=4) if(int(head-mathNum)=int(atof(findStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) returnfirstStd; elseif(type=5) if(int(head-englishNum)=int(atof(findStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) returnfirstStd; elseif(type=6) if(int(head-result)=int(atof(findStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) returnfirstStd; elseif(type=7) if(int(head-average)=int(atof(findStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) returnfirstStd; elseif(type=8) if(int(head-pos)=int(atof(findStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) returnfirstStd; head=head-next; if(isFind=false) cout找不到你要找的记录.next=NULL) break; head=head-next; strcpy(pS-name,pNew-name); pS-num=pNew-num; pS-chinaNum=pNew-chinaNum; pS-englishNum=pNew-englishNum; pS-mathNum=pNew-mathNum; pS-next=NULL; pEnd-next=pS; head=pHead; voidInsertFront(student*&head,student*pNew) student*pHead=newstudent; strcpy(pHead-name,pNew-name); pHead-num=pNew-num; pHead-chinaNum=pNew-chinaNum; pHead-englishNum=pNew-englishNum; pHead-mathNum=pNew-mathNum; pHead-next=head; head=pHead; intGetLength(student*head) intlen=0; while(head) len+; head=head-next; returnlen; voidDelete(student*&head,char*delStr,intdelNum) student*pDel,*pNew,*pHead; boolisFind=false; pHead=head; if(strcmp(head-name,delStr)=0) pNew=head-next; deletehead; head=pNew; if(delNum=2) coutendl因为要删除的记录在前面,所有只删除第一记录.next) if(delNum=2) if(strcmp(head-next-name,delStr)=0) pNew=head-next-next; pDel=head-next; deletepDel; head-next=pNew; head=pHead; isFind=true; else if(strcmp(head-next-name,delStr)=0) pNew=head-next-next; pDel=head-next; deletepDel; head-next=pNew; head=pHead; return; head=head-next; head=pHead; if(isFind=false) cout找不到你要删除的记录.endl; else cout删除记录成功.chinaNum); elseif(type=2) maxNum=int(head-mathNum); elseif(type=3) maxNum=int(head-englishNum); elseif(type=4) maxNum=int(head-result); elseif(type=5) maxNum=int(head-average); elseif(type=6) maxNum=head-pos; else cout你输入错误,请重新输入.endl; return; while(head) if(maxOrMin=1) if(type=1) if(maxNumchinaNum) maxNum=int(head-chinaNum); elseif(type=2) if(maxNummathNum) maxNum=int(head-mathNum); elseif(type=3) if(maxNumenglishNum) maxNum=int(head-englishNum); elseif(type=4) if(maxNumresult) maxNum=int(head-result); elseif(type=5) if(maxNumaverage) maxNum=int(head-average); elseif(type=6) if(maxNumpos) maxNum=head-pos; else if(type=1) if(maxNumint(head-chinaNum) maxNum=int(head-chinaNum); elseif(type=2) if(maxNumint(head-mathNum) maxNum=int(head-mathNum); elseif(type=3) if(maxNumint(head-englishNum) maxNum=int(head-englishNum); elseif(type=4) if(maxNumint(head-result) maxNum=int(head-result); elseif(type=5) if(maxNumint(head-average) maxNum=int(head-average); elseif(type=6) if(maxNumhead-pos) maxNum=head-pos; head=head-next; head=pHead; cout姓名:setw(8)座号:setw(10) 语文分数:setw(10)数学分数: setw(10)英语分数:setw(8)总分数: setw(8)平均分:setw(5)名次:endlchinaNum)=maxNum) Print(head); elseif(type=2) if(int(head-mathNum)=maxNum) Print(head); elseif(type=3) if(int(head-englishNum)=maxNum) Print(head); elseif(type=4) if(int(head-result)=maxNum) Print(head); elseif(type=5) if(int(head-average)=maxNum) Print(head); elseif(type=6) if(head-pos=maxNum) Print(head); head=head-next; voidReword(student*pStd) if(pStd!=NULL) cout请输入学生的新名字:pStd-name; cout请输入学生的座号pStd-num; cout请输入学生的语文分数pStd-chinaNum; cout请输入学生的数学分数pStd-mathNum; cout请输入学生的英语分数pStd-englishNum; else return; voidSort(student*&head,chartype,charmaxOrMin) /*参数说明: type=1按语文排列 type=2按数学排列 type=3按英语排列 type=4按总分排列 type=5按平均分排列 type=6按座号排列 */ student*pHead,*pH; pHead=pH=head; intlen=GetLength(head); float*array=newfloatlen; inti; intx=0; floatnum=0; while(head) Count(head); if(type=1) num=head-chinaNum; elseif(type=2) num=head-mathNum; elseif(type=3) num=head-englishNum; elseif(type=4) num=head-result; elseif(type=5) num=head-average; elseif(type=6) num=head-num; arrayx=num; x+; head=head-next; head=pHead; if(maxOrMin=1) for(i=1;ilen;i+) for(intj=0;jlen-i;j+) if(arrayjarrayj+1) floatnum; num=arrayj; arrayj=arrayj+1; arrayj+1=num; else for(i=1;ilen;i+) for(intj=0;jarrayj+1) floatnum; num=arrayj; arrayj=arrayj+1; arrayj+1=num; intpos=1; for(i=0;ichinaNum; elseif(type=2) num=head-mathNum; elseif(type=3) num=head-englishNum; elseif(type=4) num=int(head-result); elseif(type=5) num=int(head-average); elseif(type=6) num=int(head-num); intn=0; if(int(arrayi)=int(num) if(int(arrayi)!=int(arrayi+1) if(n=0) n=pos; head-pos=pos; pos+; else head-pos=n; head=head-next; head=pH; deletearray; voidCount(student*&head) head-result=head-chinaNum+head-englishNum+head-mathNum; head-average=head-result/3; voidDeleteAll(student*&head) student*cp,*np; cp=head; while(cp) np=cp-next; deletecp; cp=np; head=NULL; voidChaXun(stringstr,student*head) Sort(head,4,1); cout欢迎使用查询功能endlendl; cout一般查询2-查找最多3-查找最少s; while(s0!=1&s0!=2&s0!=3) cout你输入错误,请重新输入.s; if(s0=1) cout按什么查询?endl; cout姓名2-座号3-语文成绩4-数学成绩 英语成绩6-总分7-平均分8-排名str; while(str0!=1&str0!=2& str0!=3&str0!=4& str0!=5&str0!=6& str0!=7&str0!=8) cout你输入错误,请重新输入.str; charfindStr30; cout请输入要查找的关键字或关键数:findStr; switch(str0) case1: Find(head,findStr,1); break; case2: Find(head,findStr,2); break; case3: Find(head,findStr,3); break; case4: Find(head,findStr,4); break; case5: Find(head,findStr,5); break; case6: Find(head,findStr,6); break; case7: Find(head,findStr,7); break; case8: Find(head,findStr,8); break; elseif(s0=2) cout请输入要按什么查询?endl; cout语文成绩2-数学成绩 英语成绩4-总分5-平均分6-排名s; switch(s0) case1: FindMaxOrMin(head,1,1); break; case2: FindMaxOrMin(head,2,1); break; case3: FindMaxOrMin(head,3,1); break; case6: FindMaxOrMin(head,6,1); break; case5: FindMaxOrMin(head,5,1); break; default: FindMaxOrMin(head,4,1); break; elseif(s0=3) cout请输入要按什么查询?endl; cout语文成绩2-数学成绩 英语成绩4-总分5-平均分6-排名s; switch(s0) case1: FindMaxOrMin(head,1,2); break; case2: FindMaxOrMin(head,2,2); break; case3: FindMaxOrMin(head,3,2); break; case6: FindMaxOrMin(head,6,2); break; case5: FindMaxOrMin(head,5,2); break; default: FindMaxOrMin(head,4,2); break; voidZengJia(stringstr,student*&head) student*pNew=newstudent; cout欢迎使用增加功能endlendl; cout请输入新学生的名字:pNew-name; cout请输入新学生的座号:pNew-num; cout请输入他的语文分数:pNew-chinaNum; cout请输入他的数学分数pNew-mathNum; cout请输入他的英语分数pNew-englishNum; cout最前面2-最后面)str; while(str0!=1&str0!=2) cout你输入错误,请重新输入.endl; cout最前面2-最后面)str; if(str0=1) InsertFront(head,pNew); elseif(str0=2) InsertRear(head,pNew); cout新学生增加成功.endl; voidShanChu(stringstr,student*&head) chardelStr30; cout欢迎使用删除功能endlendl; cout查询删除2-全部删除str; while(str0!=1&str0!=2) cout输入错误,请重新输入.str; if(str0=1) cout请输入要删除的关键字delStr; cout删除第一条找到的记录2-删除所有找到的记录str; while(str0!=1&str0!=2) cout你输入错误,请重新输入.str; cout删除2-取消s; if(str0=1) if(str0=1) Delete(head,delStr,1); else Delete(head,delStr,2); else cout你已经取消删除了.endl; else cout你真的要删除全部数据吗?这样会使你的数据全部丢失哦.endl; cout全部删除2-取消删除str; if(str0=1) DeleteAll(head); else cout你已经取消删除了.endl; voidPaiMing(stringstr,student*head) strings; cout欢迎使用排名功能endlendl; cout升序2-降序s; cout请输入要按什么排名?endl; cout语文成绩2-数学成绩3-英语成绩 总分5-平均分6-座号str; while(str0!=1&str0!=2& str0!=3&str0!=4& str0!=5&str0!=6) cout你输入错误,请重新输入.str; cout姓名:setw(8)座号:setw(10) 语文分数:setw(10)数学分数: setw(10)英语分数:setw(8)总分数: setw(8)平均分:setw(6)名次:endlendl; if(s0=2) switch(str0) case1: Sort(head,1,1); break; case2: Sort(head,2,1); break; case3: Sort(head,3,1); break; case4: Sort(head,4,1); break; case5: Sort(head,5,1); break; case6: Sort(head,6,1); break; else switch(str0) case1: Sort(head,1,2);

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论