《2023年简单学生信息管理系统C++范文.docx》由会员分享,可在线阅读,更多相关《2023年简单学生信息管理系统C++范文.docx(27页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、2023年简单学生信息管理系统C+范文 第一篇:简洁学生信息管理系统C+范文 #include #include using namespace std; int i=0; void layout() coutbanjinumnamesexscore1score2; stu.set_student(banji,num,name,sex,score1,score2); i+; coutx; while(x=0); show_1(); for(j=0;jx; int p; for(p=0;px; int p; for(p=0;pbanjinumnamesexscore1score2; stu.se
2、t_student(banji,num,name,sex,score1,score2); show_1(); for(j=0;jflag; switch(flag) case 0: coutsn;char fileName;chainList headNode(0,NULL);chainList *head=&headNode;if(sn=l)ifstream file; coutfileName; file.open(fileName);if(!file)/为何输入不存在地文件后,机子变得很慢,而且没有结果出来? coutctn;switch(ctn) case 0:break;case 1
3、: addList(head); break;case 2: coutnm; chainList *pdel; pdel=searchList(head,nm); char sure;/Make sure whether you want to delete the data sure=n; if(!pdel-next) coutnext-pl-print(); coutsure; if(sure=y) deleteNode(pdel); coutnm1;chainList *pp; pp=searchList(head,nm1); if(pp-next) coutnext-pl-print(
4、); coutname; chainList *p; p=searchList(head,name); if(p-next) p-next-pl-print(); else coutch; switch(ch) case 1: coutsave;if(save!=n) coutfileName; ofstream fin; fin.open(fileName);/假如文件已经存在,询问是否覆盖。如何知道是否存在 if(!fin) couttp;while(tp) ffag; ffnm; ffsx; switch(tp) case 1: ffgrd;ffschl; psn=new student
5、(ag,nm,sx,grd,schl,e,m,g,average); break;case 2: ffsb; ffteaYear; psn=new teacher(ag,nm,sx,sb,teaYear); break;case 3: ffslr; psn=new empoyee(ag,nm,sx,slr); break; chainList*s=new chainList(tp,psn);p-next=s;p=s;fftp;void fileWrite(chainList *list,ofstream &ff) chainList*p=list-next;while(p) ffagename
6、sextypeOfPn) case 1: ff gradenext; int aa=0;ffp2) return 1; else return-1; void addList(chainList *list)/添加节点 char tp;int type;do couttp;/为什么一输入字符就死循环? char nm;int ag;char sx;int slr;int grd;char schl; int e;int m; int g;int average;char sb;int teaYear;int aa=1;persons*psn;/插入人员指针 switch(tp) case 0:
7、aa=0; type=0; break;case 1: type=1; coutnm; coutag; coutsx; coutgrd; coutschl; coute; coutm; coutg; coutnm; coutag; coutsx; coutsb; coutteaYear; psn=new teacher(ag,nm,sx,sb,teaYear); break; case 3:type=3; coutnm; coutag; coutsx; coutslr; psn=new empoyee(ag,nm,sx,slr); break; default:type=6; aa=0; co
8、utnext) com=compareStr(nm,p-next-pl-name); coutnext&com0)/比p节点小或者p为空退出 p=p-next; if(p-next) com=compareStr(nm,p-next-pl-name); chainList *s=new chainList(type,psn); s-next=p-next; p-next=s; while(type); void deleteNode(chainList *node) chainList*ptemp=node-next; node-next=ptemp-next; delete ptemp; v
9、oid editList(chainList *list,char *name)/删除,添加就是编辑。缺点:不想删除的也被删除了。 chainList *pde;pde=searchList(list,name); char tp;int type;do couttp;/为什么一输入字符就死循环? char nm; int ag; char sx; int slr; int grd; char schl; int e; int m; int g; int average; char sb; int teaYear; int aa=1; persons*psn;/插入人员指针 if(tp=1|t
10、p=2|tp=3) deleteNode(pde);switch(tp) case 0:aa=0;type=0;break;case 1: type=1;coutnm;coutag;coutsx;coutgrd;coutschl;coute;coutm;coutg;psn=new student(ag,nm,sx,grd,schl,e,m,g,average);break;case 2:type=2;coutnm;coutag;coutsx;coutsb;coutteaYear;psn=new teacher(ag,nm,sx,sb,teaYear);break;case 3:type=3;c
11、outnm; coutag; coutsx; coutslr; psn=new empoyee(ag,nm,sx,slr); break; default:type=6; aa=0; coutnext) com=compareStr(nm,p-next-pl-name); coutnext&com0)/比p节点小或者p为空退出 p=p-next; if(p-next) com=compareStr(nm,p-next-pl-name); chainList *s=new chainList(type,psn); s-next=p-next; p-next=s; while(type); cha
12、inList *searchList(chainList *list,char*name)/查找函数 chainList *p=list;int com;if(p-next) com=compareStr(name,p-next-pl-name); while(p-next&com)/com为0值即名字相同或者pnext为空退出 p=p-next;if(p-next)com=compareStr(name,p-next-pl-name); return p; void orderList(chainList *list) chainList *p,*q;p=list;q=p-next;whil
13、e(q-next&p) while(p-next!=q-next)&p-next)/假如相等,则什么也不做 int i=compareStr(q-next-pl-name,p-next-pl-name); i=-i; if(i0)/字母依次小的插在前面 chainList*s; s=q-next; q-next=s-next; s-next=p-next; p-next=s; p=s; break; if(i=0)/字母依次相同的插到后面 chainList*ss; ss=q-next; q-next=ss-next; p=p-next;/让p恒久指向插入位置前一个位置。 ss-next=p-
14、next; p-next=ss; p=ss; break; p=p-next; p=list;/让p重新指向头节点。 if(q-next) q=q-next;/q前进一步。 void orderListByAge(chainList *list) chainList*p,*q;p=list;q=p-next;while(q-next&p) while(p-next!=q-next)/假如相等,则什么也不做 int i=q-next-pl-age-p-next-pl-age; if(i0)/年龄大的插到用于比较的节点前面 chainList*s; s=q-next; q-next=s-next;
15、 s-next=p-next; p-next=s; p=s; break; if(i=0)/年龄相同的插到后面 chainList*ss; ss=q-next; q-next=ss-next; p=p-next;/让p恒久指向插入位置前一个位置。 ss-next=p-next; p-next=ss; p=ss; break; p=p-next; p=list;/让p重新指向头节点。 if(q-next) q=q-next;/q前进一步。 void orderListBySex(chainList *list)/按性别排序,插入排序 chainList*p,*q;p=q=list; while(
16、q-next) if(q-next-pl-sex=f) chainList*s; s=q-next; q-next=s-next;/删除,然后插到前面 s-next=p-next; p-next=s; p=s; q=q-next; void printStaticInfo(chainList*list) int count,countS,countT,countE,countMale,countFemale;count=countS=countT=countE=countMale=countFemale=0;chainList*p=list-next;while(p) p-pl-print()
17、; count+; if(p-pl-sex=m) countMale+; else countFemale+; switch(p-typeOfPn) case 1: countS+; break; case 2: countT+; break;case 3: countE+; break; p=p-next; cout(istream& input,Telem& T); friend ostream& operatorc) switch(c) case 1: coutdata; data.year=now-data.birthtime; iofile.write(char*)&data,siz
18、eof(data); coutans; while(y=ans|Y=ans);loop: if(1=flag) coutdata; data.year=now-data.birthtime; iofile.write(char*)&data,sizeof(data); coutdata; data.year=now-data.birthtime; iofile.write(char*)&data,sizeof(data); coutans; while(y=ans|Y=ans);loop: if(1=flag) coutdata; data.year=now-data.birthtime; i
19、ofile.write(char*)&data,sizeof(data); cout(istream& input,Telem& T) int y,m,d; coutymd; T.birthtime.year=(y=1900&y=1&m=1&dymd; T.worktime.year=(y=1900&y=1&m=1&dc; switch(c) case 1: coutAddall(); coutAddall(); break; case 2: coutk; if(1=k) pt-Add(); else if(2=k) ps-Add(); else coutDisplay(); ps-Displ
20、ay(); break; case 4: coutk; if(1=k) coutDisplaypart(part); else if(2=k) coutDisplaypart(part); else coutk; if(1=k) coutl; if(1=l) coutFindname(nam); else if(2=l) couti; pt-Findyear(i); else coutl; if(1=l) coutFindname(nam); else if(2=l) couti; ps-Findyear(i); else coutMN; coutEmployee:Employeename;
21、Employee:Employeenum = EmployeeMaxNum + Employee:MaxNum()+1; coutEmployee:Employeesex; coutEmployee:Employeeage; coutEmployee:Employeemarriage; coutEmployee:Employeedegree; while(Employee:Employeedegree!=1&Employee:Employeedegree!=2&Employee:Employeedegree!=3&Employee:Employeedegree!=4&Employee:Empl
22、oyeedegree!=5&Employee:Employeedegree!=6) coutEmployee:Employeedegree; coutEmployee:Employeedepart; while(Employee:Employeedepart!=1&Employee:Employeedepart!=2&Employee:Employeedepart!=3&Employee:Employeedepart!=4&Employee:Employeedepart!=5&Employee:Employeedepart!=6&Employee:Employeedepart!=7) cout
23、Employee:Employeedepart; coutEmployee:Employeeposition; while(Employee:Employeeposition!=1&Employee:Employeeposition!=2&Employee:Employeeposition!=3&Employee:Employeeposition!=4&Employee:Employeeposition!=5) coutEmployee:Employeeposition; coutEmployee:Employeeworktime; Employee:Employeepay = Employe
24、e:Pay(Employee:Employeeposition); DBOperate dbo; dbo.ReadOut(); int MaxNum = Employee:MaxNum(); Enum = Employee:Employeenum; Ename = Employee:Employeename; Esex = Employee:Employeesex; Eage = Employee:Employeeage; Emarriage = Employee:Employeemarriage; Edegree = Employee:Employeedegree; Edepart = Em
25、ployee:Employeedepart; Eposition = Employee:Employeeposition; Eworktime = Employee:Employeeworktime; Epay = Employee:Employeepay; dbo.WriteIn(1); coutchoice1; switch(choice1) case 1: showall();break; case 2: coutchoice2; e.showdepart(choice2);break; case 3: coutchoice2; e.showdegree(choice2);break;
26、case 4: coutmin; coutmax; e.showage(min,max);break; case 5: coutsearchnum; e.shownum(searchnum);break; default: cout=min&EagecNum; int MN; MN = Employee:MaxNum(); for(int i=0;iEmployee:Employeename; Ename = Employee:Employeename; coutEmployee:Employeesex; Esex = Employee:Employeesex; coutEmployee:Em
27、ployeeage; Eage = Employee:Employeeage; coutEmployee:Employeemarriage; Emarriage = Employee:Employeemarriage; coutEmployee:Employeedegree; while(Employee:Employeedegree!=1&Employee:Employeedegree!=2&Employee:Employeedegree!=3&Employee:Employeedegree!=4&Employee:Employeedegree!=5&Employee:Employeedeg
28、ree!=6) coutEmployee:Employeedegree; Edegree = Employee:Employeedegree; coutEmployee:Employeedepart; while(Employee:Employeedepart!=1&Employee:Employeedepart!=2&Employee:Employeedepart!=3&Employee:Employeedepart!=4&Employee:Employeedepart!=5&Employee:Employeedepart!=6&Employee:Employeedepart!=7) cou
29、tEmployee:Employeedepart; Edepart = Employee:Employeedepart; coutEmployee:Employeeposition; while(Employee:Employeeposition!=1&Employee:Employeeposition!=2&Employee:Employeeposition!=3&Employee:Employeeposition!=4&Employee:Employeeposition!=5) coutEmployee:Employeeposition; Eposition = Employee:Empl
30、oyeeposition; coutEmployee:Employeeworktime; Eworktime = Employee:Employeeworktime; Epay = Employee:Pay(Employee:Employeeposition); break; dbo.WriteIn(0); void Employee:DeleteInfo()/删除职工数据的函数 char tmp; int cNum = 1000; DBOperate dbo; dbo.ReadOut(); void Employee:shownum(long number); coutcNum; int M
31、N; MN = Employee:MaxNum(); for(int i=0;itmp; if(tmp=Y) if(i=MN-1) dbo.WriteIn(-1); else for(int j=i;jDBOperate:EmployeenumDBOperate:EmployeenameDBOperate:EmployeesexDBOperate:EmployeeageDBOperate:Employeemarriage DBOperate:EmployeedegreeDBOperate:EmployeedepartDBOperate:EmployeepositionDBOperate:Emp
32、loyeeworktimeDBOperate:Employeepay; Enum = DBOperate:Employeenum; Ename = DBOperate:Employeename; Esex = DBOperate:Employeesex; Eage = DBOperate:Employeeage; Emarriage = DBOperate:Employeemarriage; Edegree = DBOperate:Employeedegree; Edepart = DBOperate:Employeedepart; Eposition = DBOperate:Employee
33、position; Eworktime = DBOperate:Employeeworktime; Epay = DBOperate:Employeepay; myf.close(); void DBOperate:RefreshMaxNum(int iflag)/更新系统中员工计数文件的函数 int MaxNum = 0; ifstream myif(“EmployeeMaxNum.txt); myifMaxNum; myif.close(); MaxNum = MaxNum+iflag; ofstream myof(“EmployeeMaxNum.txt); myofselect; Employee e; DBOperate dbo; switch(select) case 1: e.NewInfo();break; case 2: dbo.ReadOut(); e.ShowInfo();break; case 3: e.RefreshInfo();break; case 4: e.DeleteInfo();break; case 5: cout“ 退出胜利endl;break; default: cout“叮嘱错误!endl; if(select = 5) break; exit(1); return 0;