c++图书管理系统-数据结构课程设计|数据结构课程设计
#include
#include#includestatic int n=0;int comp(char*,char*);class student{public: void getdata() { tag='#'; cout<<"(姓名 身份证号码 班级 成绩):"; cin>>name>>number>>Class>>score; } char gettag() { return tag; } void disp() { if(tag=='#') cout<>name>>number>>zhichen>>xueyuan; } char gettag() { return tag; } void disp() { if(tag=='#') cout<class studentteacher{public: void getdata() { tag='#'; cout<<"(姓名 身份证号码 班级 成绩 职称 学院):"; cin>>name>>number>>Class>>score>>zhichen>>xueyuan; } char gettag() { return tag; } void disp() { if(tag=='#') cout<>n; for(int i=0;i>sname; cout<<"输出查询结果:"<>sname; while(!outdel.eof()) { outdel.seekp(sizeof(student)*i); outdel.read((char *)&one,sizeof(one)); if(comp(one.getname(),sname)==1&&one.gettag()=='#') { outdel.seekp(sizeof(student) *i); outdel.put('*'); } i++; } outdel.close();}void func6(){ fstream outdel("student.dat",ios::in); fstream temp("temp",ios::out|ios::trunc); student s; while(!outdel.eof()) { outdel.read((char *)&s,sizeof(student)); if(s.gettag()=='#') temp.write((char *)&s,sizeof(student)); } outdel.close(); temp.close(); fstream outdel1("MyFrd.dat",ios::out|ios::trunc); fstream temp1("temp",ios::in); while(!temp1.eof()) { temp1.read((char *)&s,sizeof(student)); outdel1.write((char *)&s,sizeof(student)); } outdel1.close(); temp1.close(); cout<<"此记录已物理删除"<
void func7(){ ofstream output("MyFrd1.dat"); teacher s; cout<<"输入数据"<>n; for(int i=0;i>sname; cout<<"输出查询结果:"<>sname; while(!outdel.eof()) { outdel.seekp(sizeof(teacher)*i); outdel.read((char *)&one,sizeof(one)); if(comp(one.getname(),sname)==1&&one.gettag()=='#') { outdel.seekp(sizeof(teacher) *i); outdel.put('*'); } i++; } outdel.close();}void func02(){ fstream outdel("teacher.dat",ios::in); fstream temp("temp",ios::out|ios::trunc); teacher s; while(!outdel.eof()) { outdel.read((char *)&s,sizeof(teacher)); if(s.gettag()=='#') temp.write((char *)&s,sizeof(teacher)); } outdel.close(); temp.close(); fstream outdel1("MyFrd1.dat",ios::out|ios::trunc); fstream temp1("temp",ios::in); while(!temp1.eof()) { temp1.read((char *)&s,sizeof(teacher)); outdel1.write((char *)&s,sizeof(teacher)); } outdel1.close(); temp1.close(); cout<<"此记录已物理删除"<>n; for(int i=0;i
void func04(){ ifstream input("MyFrd2.dat"); studentteacher s; cout<<"输出数据"<>sname; cout<<"输出查询结果:"<>sname; while(!outdel.eof()) { outdel.seekp(sizeof(studentteacher)*i); outdel.read((char *)&one,sizeof(one)); if(comp(one.getname(),sname)==1&&one.gettag()=='#') { outdel.seekp(sizeof(studentteacher) *i); outdel.put('*'); } i++; } outdel.close();}void func08(){ fstream outdel("studentteacher.dat",ios::in); fstream temp("temp",ios::out|ios::trunc); studentteacher s; while(!outdel.eof()) { outdel.read((char *)&s,sizeof(studentteacher)); if(s.gettag()=='#') temp.write((char *)&s,sizeof(studentteacher)); } outdel.close(); temp.close(); fstream outdel1("MyFrd2.dat",ios::out|ios::trunc); fstream temp1("temp",ios::in); while(!temp1.eof()) { temp1.read((char *)&s,sizeof(studentteacher)); outdel1.write((char *)&s,sizeof(studentteacher)); } outdel1.close(); temp1.close(); cout<<"此记录已物理删除"<>sname; cout<<"输出查询结果:"<>sname; cout<<"输出查询结果:"<
void func11(){ char sname[10]; ifstream file("MyFrd2.dat"); studentteacher one; file.seekg(0); cout<<"输入要修改的姓名(可只输入姓氏):"; cin>>sname; cout<<"输出查询结果:"<
}int comp(char s1[],char s2[]){ int i=0; while(s1[i]!='\0'&&s2[i]!='\0'&&s1[i]==s2[i]) i++; if(s1[i]=='\0'||s2[i]=='\0') return 1; else return 0;}void main(){ int sel; do { cout<<"请输入(1:输入数据 2:输出数据 3:按姓名查询"<>sel; switch(sel) { case 1: char a,b; while(1) { cout<<"请输入你所选择的操作对象(学生(1),老师(2),研究生(3)):"; cin>>a; if(a=='1') func1(); else if(a=='2') func7(); else if(a=='3') func03(); else cout<<"输入错误!"<>b; while(b!='y'&&b!='Y'&&b!='n'&&b!='N') { cout<<"对不起,你输入错误!请重新输入:"; cin>>b; } if(b=='n'||b=='N') break; } break; case 2: char c,d; while(1) { cout<<"请输入你所选择的操作对象(学生(1),老师(2),研究生(3)):"; cin>>c; if(c=='1') func2(); else if(c=='2') func8(); else if(c=='3') func04(); else cout<<"输入错误!"<>d; while(d!='y'&&d!='Y'&&d!='n'&&d!='N') { cout<<"对不起,你输入错误!请重新输入:"; cin>>d; } if(d=='n'||d=='N') break; } break; case 3: char e,f; while(1) { cout<<"请输入你所选择的操作对象(学生(1),老师(2),研究生(3)):"; cin>>e; if(e=='1') func3(); else if(e=='2') func9(); else if(e=='3') func04(); else cout<<"输入错误!"<>f; while(b!='y'&&b!='Y'&&b!='n'&&b!='N') { cout<<"对不起,你输入错误!请重新输入:"; cin>>f; } if(f=='n'||f=='N') break; } break; case 4: char g,h; while(1) { cout<<"请输入你所选择的操作对象(学生(1),老师(2),研究生(3)):"; cin>>g; if(g=='1') func4(); else if(g=='2') func0(); else if(g=='3') func06(); else cout<<"输入错误!"<>h; while(h!='y'&&h!='Y'&&h!='n'&&h!='N') { cout<<"对不起,你输入错误!请重新输入:"; cin>>h; } if(h=='n'||h=='N') break; } break; case 5: char m,n; while(1) { cout<<"请输入你所选择的操作对象(学生(1),老师(2),研究生(3)):"; cin>>m; if(m=='1') func5(); else if(m=='2') func01(); else if(m=='3') func07(); else cout<<"输入错误!"<>n; while(n!='y'&&n!='Y'&&n!='n'&&n!='N') { cout<<"对不起,你输入错误!请重新输入:"; cin>>n; } if(n=='n'||n=='N') break; } break; case 6: char x,z; while(1) { cout<<"请输入你所选择的操作对象(学生(1),老师(2),研究生(3)):"; cin>>x; if(x=='1') func6(); else if(x=='2') func02(); else if(x=='3') func08(); else cout<<"输入错误!"<>z; while(z!='y'&&z!='Y'&&z!='n'&&z!='N') { cout<<"对不起,你输入错误!请重新输入:"; cin>>z; } if(z=='n'||z=='N') break; } break; case 7: char s,t; while(1) { cout<<"请输入你所选择的操作对象(学生(1),老师(2),研究生(3)):"; cin>>s; if(s=='1') func09(); else if(s=='2') func10(); else if(s=='3') func11(); else cout<<"输入错误!"<>t; while(t!='y'&&t!='Y'&&t!='n'&&t!='N') { cout<<"对不起,你输入错误!请重新输入:"; cin>>t; } if(t=='n'||t=='N') break; } break; default: cout<<"输入错误!"<=1&&sel<=6);}