校园信息管理系弘之模板法
上传用户:yu198211
上传日期:2024-12-14
文件大小: 6k
源码售价: 10 个金币 积分规则     积分充值
资源说明:#include #include #include #include "Class.h" #define ok 1 #define error 0 void tongji::tsave() //保存统计对象 { ofstream outfile("statics.dat",ios::out); if(!outfile) { cerr<<"open error!"<>c.tcount; infile>>c.scount; infile.close(); return (c); } // void person::show()const // 输出person { cout<<"姓名:"<>name; cout<>sex; cout<>address; cout<<"出生日期"<>year; cout<>month; cout<>data; cout<>sclass; cout<>major; cout<>course; cout<>sregister; cout<>*p; infile.close(); } istream&operator>>(istream&input,Student &stud) //重载cin { input>>stud.name; input>>stud.sex; input>>stud.address; input>>stud.year; input>>stud.month; input>>stud.data; input>>stud.sclass; input>>stud.major; input>>stud.course; input>>stud.sregister; return input; } ostream&operator<<(ostream&output,Student &stud) //重载cout { output<>(istream&input,Teacher &t) //重载cin { input>>t.name; input>>t.sex; input>>t.address; input>>t.year; input>>t.month; input>>t.data; input>>t.course; input>>t.tregister; return input; } ostream&operator<<(ostream&output,Teacher &t) //重载cout { output<>course; cout<>tregister; cout<>*p; infile.close(); }//teacher typedef struct Snode { Student data; struct Snode *next; }Snode,*SLinklist; //学生结点 //void Createlist_l(Snode &SL,int n,Student &ps) //{ //int i; //Snode *p; //SL=(SLinklist)malloc(sizeof(Snode)); //SL->next=NULL; //for(i=n;i>0;--i) //{ // p=(SLinklist)malloc(sizeof(Snode)); //p->data=ps; //p->next=SL->next; //SL->next=p; // } // return SL; //}//创建学生链表 int SlisTdelete_L(SLinklist &SL,int i) //删除学生链表 { Snode *p,*q; int j=1; p=SL; while(p->next&&jnext; ++j; } if(!(p->next)||j>i-1) return error; q= p->next; p->next=q->next; free(q); //scount--; return ok; } typedef struct Tnode { Teacher data; struct Tnode *next; }Tnode,*TLinklist; //老师结点 void Createlist_l(TLinklist &TL,int n,Teacher &pt) { int i; Tnode *p; TL=(TLinklist)malloc(sizeof(Tnode)); TL->next=NULL; for(i=n;i>0;--i) { p=(TLinklist)malloc(sizeof(Tnode)); p->data=pt; p->next=TL->next; TL->next=p; } } //创建老师链表 int TlisTdelete_L(TLinklist &TL,int i) { Tnode *p,*q; int j=1; p=TL; while(p->next&&jnext; ++j; } if(!(p->next)||j>i-1) return error; q= p->next; p->next=q->next; free(q); //tcount--; return ok; } //删除老师链表 void input() //选择操作 { cout<<"请选择是要输入学生的数据还是老师的?"<>n; tongji c; ifstream infile("statics.dat",ios::in); if(!infile) { cerr<<"open error!"<>p->tcount; infile>>p->scount; infile.close(); if(n=="a") { Student *ps=new Student; ps->read(); cout<<"是否保存在文件中,y/n?"<>m; if(m=="y") { ps->save(ps); cout << " 成功保存数据!"; delete ps; p->scount=p->scount+1; p->tsave(); } } else if(n=="b") { Teacher *pt=new Teacher; pt->read(); cout<<"是否保存在文件中,y/n?"<>m; if(m=="y") { pt->save(pt); cout << "成功保存数据!" ; delete pt; p->tcount=p->tcount+1; p->tsave(); } } else cout<<"你的输入有错!"<>m; ifstream infile("statics.dat",ios::in); if(!infile) { cerr<<"open error!"<>pj->tcount; infile>>pj->scount; if(m=='a') { ifstream infile("student.dat",ios::in); if(!infile) { cerr<<"open error!"<scount;j++) { Student *p=new Student; infile>>p->name; infile>>p->sex; infile>>p->address; infile>>p->year; infile>>p->month; infile>>p->data; infile>>p->sclass; infile>>p->major; infile>>p->course; infile>>p->sregister; p->show(); delete p; } infile.close(); } else if(m=='b') { ifstream infile("teacher.dat",ios::in); if(!infile) { cerr<<"open error!"<tcount;j++) { Teacher *TL=new Teacher; infile>>TL->name; infile>>TL->sex; infile>>TL->address; infile>>TL->year; infile>>TL->month; infile>>TL->data; infile>>TL->course; infile>>TL->tregister; TL->show(); delete(TL); } infile.close(); } else cout<<"你的输入有错!"<>m; ifstream infile("statics.dat",ios::in); if(!infile) { cerr<<"open error!"<>pj->tcount; infile>>pj->scount; if(m=="a") { string mz; int sflag=0; int j; Snode *l=new Snode; //建立一个学生的空链表 l->next=NULL; Snode *p=l; //等下可先存放在stu中 cout<<"请输入你想删除的学生的名字:"; cin>>mz; ifstream infile("student.dat",ios::in); if(!infile) { cerr<<"open error!"<scount;j++) { Snode *ps=new Snode; infile>>ps->data.name; infile>>ps->data.sex; infile>>ps->data.address; infile>>ps->data.year; infile>>ps->data.month; infile>>ps->data.data; infile>>ps->data.sclass; infile>>ps->data.major; infile>>ps->data.course; infile>>ps->data.sregister; if(mz==ps->data.name)sflag=j+1; p->next=ps; ps->next=NULL; p=p->next; // ps->next=l->next; //学生的链表 // l->next=ps; } infile.close(); Snode *ps; if(sflag!=0) { SlisTdelete_L(l,sflag); ps=l->next; pj->scount=pj->scount-1; cout<<"删除后的其他学生的资料如下:"<scount;j++) { ps->data.show(); ps=ps->next; } char t; cout<<"是否保存在student.dat中y/n?"<>t; if(t=='y') { //7 pj->tsave(); ofstream outfile("student.dat",ios::out); if(!outfile) {//8 cerr<<"open error!"<next; for(j=1;j<=pj->scount;j++) { ps->data.save(&(ps->data)); ps=ps->next; pj->tsave(); } outfile.close(); cout<<"保存成功!"<next=NULL; //建立一个老师的空链表 cout<<"请输入你想删除的老师的名字:"; cin>>mz; ifstream infile("teacher.dat",ios::in); if(!infile) { cerr<<"open error!"<tcount;j++) { Tnode *pt=new Tnode; infile>>pt->data.name; infile>>pt->data.sex; infile>>pt->data.address; infile>>pt->data.year; infile>>pt->data.month; infile>>pt->data.data; infile>>pt->data.course; infile>>pt->data.tregister; if(mz==pt->data.name)tflag=j+1; p->next=pt; pt->next=NULL; p=p->next; // pt->next=l->next; //建立老师的链表 //l->next=pt; } infile.close(); Tnode *pt; if(tflag!=0) { //for(j=tflag;j<=pj->tcount;j++)teach[j]=teach[j+1]; TlisTdelete_L(l,tflag); // pj->tcount= (pj->tcount)-1; pt=l->next; pj->tcount=pj->tcount-1; cout<<"删除后的其他老师的资料如下:"<tcount;j++) { pt->data.show(); pt=pt->next; } //teach[j].show(); char t; cout<<"是否保存在teacher.dat中y/n?"<>t; if(t=='y') { pj->tsave(); ofstream outfile("teacher.dat",ios::out); if(!outfile) { cerr<<"open error!"<next; for(j=1;j<=pj->tcount;j++) { pt->data.save(&(pt->data)); pt=pt->next; pj->tsave(); } outfile.close(); cout<<"保存成功!"<>pj->tcount; infile>>pj->scount; cin>>m; if(m=="a") { Snode *l=new Snode; //建立一个学生的空链表 l->next=NULL; cout<<"请输入你想查找的学生的名字:"; cin>>mz; int sflag=0; ifstream infile("student.dat",ios::in); if(!infile) { cerr<<"open error!"<scount;j++) { Snode *ps=new Snode; infile>>ps->data.name; infile>>ps->data.sex; infile>>ps->data.address; infile>>ps->data.year; infile>>ps->data.month; infile>>ps->data.data; infile>>ps->data.sclass; infile>>ps->data.major; infile>>ps->data.course; infile>>ps->data.sregister; ps->next=l->next; //建立老师的链表 l->next=ps; if(ps->data.name==mz){ps->data.show();sflag=1;} //delete p; } infile.close(); if(sflag==0)cout<<"不存在此人!"<next=NULL; //建立一个老师的空链表 string mz; int j; int tflag=0; cout<<"请输入你想查找的老师的名字:"; cin>>mz; ifstream infile("teacher.dat",ios::in); if(!infile) { cerr<<"open error!"<tcount;j++) { Tnode *p=new Tnode; infile>>p->data.name; infile>>p->data.sex; infile>>p->data.address; infile>>p->data.year; infile>>p->data.month; infile>>p->data.data; infile>>p->data.course; infile>>p->data.tregister; p->next=l->next; //建立老师的链表 l->next=p; if(p->data.name==mz){p->data.show();tflag=1;} //delete p; } infile.close(); if(tflag==0) cout<<"不存在此人!"<>m; ifstream infile("statics.dat",ios::in); if(!infile) { cerr<<"open error!"<>p->tcount; infile>>p->scount; if(m=="a") { int sflag=0; Snode *l=new Snode; //建立一个学生的空链表 l->next=NULL; //Student stu[100];//存放学生数据 cout<<"请输入你想修改学生的名字:"<>mz; ifstream infile("student.dat",ios::in); if(!infile) { cerr<<"open error!"<scount;j++) { Snode *ps=new Snode; infile>>ps->data.name; infile>>ps->data.sex; infile>>ps->data.address; infile>>ps->data.year; infile>>ps->data.month; infile>>ps->data.data; infile>>ps->data.sclass; infile>>ps->data.major; infile>>ps->data.course; infile>>ps->data.sregister; if(ps->data.name==mz) //找到该学生并修改其相应的数据 { sflag=1; cout<<"姓名:"<>ps->data.name; cout<>ps->data.sex; cout<>ps->data.address; cout<<"出生日期"<>ps->data.year; cout<>ps->data.month; cout<>ps->data.data; cout<>ps->data.sclass; cout<>ps->data.major; cout<>ps->data.course; cout<>ps->data.sregister; cout<next=l->next; //建立学生的链表 l->next=ps; } if(sflag==0) cout<<"系统中找不到你想找的人!"<next; cout<<"是否保存修改的数据到student.dat中?y/n"<>t; if(t=="y") { ofstream outfile("student.dat",ios::out); if(!outfile) { cerr<<"open error!"<scount;j++) { outfile<data.name<<" "; outfile<data.sex<<" "; outfile<data.address<<" "; outfile<data.year<<" "; outfile<data.month<<" "; outfile<data.data<<" "; outfile<data.sclass<<" "; outfile<data.major<<" "; outfile<data.course<<" "; outfile<data.sregister<<" "; ps=ps->next; } } } } else if(m=="b") { Tnode *l=new Tnode; l->next=NULL; //建立一个老师的空链表 cout<<"请输入你想修改老师的名字:"<>tt; ifstream infile("teacher.dat",ios::in); if(!infile) { cerr<<"open error!"<tcount;j++) { Tnode *p=new Tnode; infile>>p->data.name; infile>>p->data.sex; infile>>p->data.address; infile>>p->data.year; infile>>p->data.month; infile>>p->data.data; infile>>p->data.course; infile>>p->data.tregister; if(p->data.name==tt) //找到该老师并修改其相应的数据 { tflag=1; cout<<"姓名:"<>p->data.name; cout<>p->data.sex; cout<>p->data.address; cout<<"出生日期"<>p->data.year; cout<>p->data.month; cout<>p->data.data; cout<>p->data.course; cout<>p->data.tregister; cout<next=l->next; //建立老师的链表 l->next=p; } if(tflag==0) cout<<"系统中找不到你想找的人!"<next; cout<<"是否保存修改的数据到teacher.dat中?y/n"<>t; if(t=="y") { ofstream outfile("teacher.dat",ios::out); if(!outfile) { cerr<<"open error!"<tcount;j++) { outfile<data.name<<" "; outfile<data.sex<<" "; outfile<data.address<<" "; outfile<data.year<<" "; outfile<data.month<<" "; outfile<data.data<<" "; outfile<data.course<<" "; outfile<data.tregister<<" "; pt=pt->next; } } } } else cout<<"你的输入有误!"<>m; tongji *pj=new tongji; *pj=tload(); if(m=="a") //排列学生 { Student stu[100]; ifstream infile("student.dat",ios::in); if(!infile) { cerr<<"open error!"<scount;j++) { infile>>stu[j].name; infile>>stu[j].sex; infile>>stu[j].address; infile>>stu[j].year; infile>>stu[j].month; infile>>stu[j].data; infile>>stu[j].sclass; infile>>stu[j].major; infile>>stu[j].course; infile>>stu[j].sregister; } infile.close(); for(j=1;j<=pj->scount;j++) for(i=1;i<=(pj->scount)-j;i++) if(stu[i].name>stu[i+1].name) { p=stu[i]; stu[i]=stu[i+1]; stu[i+1]=p; } cout<<"排列后的各个学生的数据如下(按名字的头个字母小到大排列):"<scount;j++) stu[j].show(); cout<<"是否要保存排列的数据,y/n?"<>m; if(m=="y") { ofstream outfile("student.dat",ios::out); if(!outfile) { cerr<<"open error!"<scount;j++) { stu[j].save(&stu[j]); } } } else if(m=="b") //排列老师 { Teacher teach[100]; ifstream infile("teacher.dat",ios::in); if(!infile) { cerr<<"open error!"<tcount;j++) { infile>>teach[j].name; infile>>teach[j].sex; infile>>teach[j].address; infile>>teach[j].year; infile>>teach[j].month; infile>>teach[j].data; infile>>teach[j].course; infile>>teach[j].tregister; } infile.close(); for(j=1;j<=pj->tcount;j++) for(i=1;i<=(pj->tcount)-j;i++) if(teach[i].name>teach[i+1].name) { p=teach[i]; teach[i]=teach[i+1]; teach[i+1]=p; } cout<<"排列后的各个老师的数据如下(按名字的头个字母小到大排列):"<tcount;j++) teach[j].show(); cout<<"是否要保存排列的数据,y/n?"<>m; if(m=="y") { ofstream outfile("teacher.dat",ios::out); if(!outfile) { cerr<<"open error!"<tcount;j++) { teach[j].save(&teach[j]); } } } else cout<<"你的输入有错!"<
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。
    
  • ffsetufree.rar格式工厂支持多种格式转换为MP4格式。 另有PSP,IPHONE专用格式大小。 ...
  • PushBox.rariPhone平台上的小游戏《推箱子》,Objective-C实现。
  • FileManager.rariPhone平台上的文件管理程序。Objective-C实现。
  • iphone.rarObject-C的入门教程,Mac OS或者iphone开发资料 英文资料
  • iphone-code.zipiphone开发基础教程源码,花了好久才找到的
  • iPhoneNetwork.rarIphone 网络编程的一个简单例子 可以帮大家快速上手iPhone程序 ...
  • iPhone-helloworld.zip实现iPhone上的hello world 演示程序。
  • iPhoneHTTPServer3.zipiphone http网络协议开发实例,很好的模板哦
  • iphone-ants.zip这款能与用户交流的“游戏”,它将为你呈现一群爬满整个屏幕的蚂蚁。基于每个独立生命 ...
  • SQLiteBooks.zipIPhone 中使用SQLlite数据库开发的实例代码,基础性代码