C++大学选修课系统设计 第10页
}
file.close();
fstream file1("student.txt",ios::out);
fstream file2("course.txt",ios::out);
while(Z)
{
file1.write ((char *)&(Z->stu),sizeof(Z->stu));
int time = Z->stu.retfactcourse();
course *co = Z->stu.retroot(),*co1;
if(co!=NULL)
co1 = co->Next;
while(time)
{
file2.write((char *)(co1),sizeof(*co1));
co1 = co1->Next;
time = time - 1;
}
Z = Z->Next;
}
file2.close ();
file1.close();
cout<<"\n\n\n\t\t\t保存数据成功!按任意键继续.."<<endl;
return 1;
}
int menu_2_0() //退出系统
{
tuichu();
return 0;
}
int main()
{
subjectdb *P = new subjectdb,*Q=P;
P->Next = NULL;
subject M;
fstream file("subject.txt",ios::in);
while(1)
{
file.read((char *)&M,sizeof(M));
if(!file) break;
Q->Next = new subjectdb;
www.751com.cn
file.close ();
studentdb *Y = new studentdb,*X=Y;
Y->Next=NULL;
student N;
course O;
fstream file1("student.txt",ios::in);
fstream file2("course.txt",ios::in);
while(1)
{
file1.read((char *)&N,sizeof(N));
if(!file1) break;
Y->Next = new studentdb;
Y->Next ->Next = NULL;
Y->Next ->stu = N;
int time = N.retfactcourse();
Y->Next->stu.clrroot ();
while(time)
{
file2.read ((char *)&O,sizeof(course));
if(!file2) break;
Y->Next->stu.addcourse(O.cname ,O.grade);
time--;
}
Y=Y->Next;
}
file2.close ();
file1.close ();
Q=P->Next;
while(Q)
{
Q->sub.clractivestudnet();
Q->sub.findstudent(X);
Q = Q->Next;
}
char c;
char b;
int br=1;
b = menu();
if(b=='1')
{www.751com.cn
while(1)
{
c = custom();
switch(c)
{
case '1':br = menu_1_1(X,P);getch();break; //学生选课
case '2':br = menu_1_2(X,P);getch();break; //学生情况
case '3':br = menu_1_3(P);getch(); break; //选课情况
case '4':br = menu_1_4(X,P); break; //退出系统
}
if (br == 0)
break;
}
}
if(b=='2')
{
password();
while(1)
{
c = server();
switch(c)
{
case '1':br = menu_2_1(X);getch(); break; //增加学生
case '2':br = menu_2_2(P);getch(); break; //增加课程
case '4':br = menu_2_4(P);getch(); break; //删除课程
case '3':br = menu_2_3(X);getch(); break; //删除学生
case '5':br = menu_2_5(X,P);getch();break; //填写成绩
case '6':br = menu_2_6(P);getch(); break; //更改学分
case '7':br = menu_2_7(X);getch(); break; //学生情况
case '8':br = menu_2_8(P);getch(); break; //选课情况
case '9':br = menu_2_9(X,P);getch();break; //保存数据
case '0':br = menu_2_0();break; //退出系统
}
if (br == 0)
break;
}
}
return 0;
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]