📄 学生选课系统.cpp
字号:
{
cout<<"\n\n\n\n\t\t您的用户名不存在!"<<endl;
exit(0);
}
fin.get();
while (!fin.eof())
{
fin>>teacher.m_ctno>>m_ctcode;
if(strcmp(m_ctcode,tcode)==0)
{
cout<<"\n\t\t\t请输入您的新密码并按回车键确认:";
strcpy(tcode,Settcode());
cout<<"\n\t\t\t请再次输入您的新密码并按回车键确认:";
if(strcmp(tcode,Settcode())==0)
{
Writef1("tcode.txt");
cout<<"修改密码成功!";
return;
}
else
cerr<<"新密码输入不一致!";
}
else
cerr<<"旧密码输入错误!";
}
}
else
cerr<<"用户名输入错误!";
}
fin.close();
}
/*********************************************************************
* *
*********************************************************************/
void tuichu(void)
{
system("cls");
system("color A4");
cout<<"\n\n\t\t\t 谢谢您的使用!\t再见!\n\n"<<endl;
cout<<"\t\t\t希望您提出宝贵意见。我们将不断改进。谢谢!\n\n"<<endl;
cout<<"\t\t\t 姓名:刘刚华 陈显清\n\n"<<endl;
cout<<"\t\t\t 学校:长沙学院\n\n\n"<<endl;
exit(0);
}
/*********************************************************************
* *
*********************************************************************/
void Memu(void)
{
system("cls");
cout<<"\n\n\n\n\n\n\n\n\t\t\t欢迎您进入学生选课系统";
Sleep(500);
system("cls");
cout<<"\n\n\n\n\n\n\t\t\t\t制作人:\n\t\t\t\t\t信科二班:\n";
cout<<"\t\t\t\t\t☆☆刘刚华☆☆☆陈显清☆☆"<<endl;
cout<<"请按任意键继续";
getch();
system("cls");
}
/*********************************************************************
* *
*********************************************************************/
int shuzi() //定义的一个容错性函数;
{
unsigned int i=1;
int j;
char ch[10];
while(1)
{
cin>>ch;
if(ch[0]=='-'||isdigit(ch[0])!=0)
{
for(;i<strlen(ch);i++)
if(isdigit(ch[i])==0)
break;
if(i+1>strlen(ch)&&!(ch[0]=='-'&&i==1))
{
j=atoi(ch);
return j;
}
else
cout<<"\t请输入数字:";
}
else
cout<<"\t请输入数字:";
}
}
/*********************************************************************
* 下面就是菜单函数了 ,对类里面的函数进行调用。 *
*********************************************************************/
int Memu3()
{
system("cls");
system("color F9");
cout<<"\n\n\n\n\n\n\t*****************************************************************\t\n\n";
cout<<"\t\t\t【☆学生选课管理☆】 \n\n";
cout<<" \t1.△选课 △\t\t";
cout<<"2.△查看已修课程及成绩△\n\n";
cout<<"\t3.△查看个人资料△\t";
cout<<"4.△退选课程△\n\n";
cout<<"\t5.△修改密码△\t\t";
cout<<"6.△查看所有课程及相关信息△\n\n";
cout<<"\t7.△切换用户△\t\t";
cout<<"0.△退出△";
cout<<"\n\n\t*****************************************************************\t\t";
cout<<"\n\t请选择:(0-7)";
int n;
n=shuzi();
while(n<=-1||n>=9)
{
cout<<"你的输入有误,请重试\n请选择:(0-9):";
n=shuzi();
}
return n;
}
/*********************************************************************
* *
*********************************************************************/
void handle_Memu3(void)
{
for(;;)
{
switch(Memu3())
{
case 1:
{
system("cls");
CSubject subject;
subject.xuanke("subject.txt");
system("cls");
break;
}
case 2:
{
system("cls");
CSubject subject;
subject.show5("subject.txt");
cout<<"请按任意键继续";
getch();
system("cls");
break;
}
case 3:
{
system("cls");
cout<<"是否继续输入: 1(是)/其它(否)";
cout<<"请按任意键继续";
getch();
system("cls");
break;
}
case 4:
{
system("cls");
cout<<"hao"<<endl;
cout<<"请按任意键继续";
getch();
system("cls");
break;
}
case 5:
{
system("cls");
CLand land;
land.modifiy("snode.txt");
cout<<"请按任意键继续";
getch();
system("cls");
break;
}
case 6:
{
system("cls");
CCourse course;
course.show2("course.txt");
cout<<"请按任意键继续";
getch();
system("cls");
break;
}
case 7:
{
system("cls");
handle_Memu1();
break;
}
case 0:
{
tuichu();
}
default:
system("cls");
cout<<"你的输入有误:";
break;
}
}
}
/*********************************************************************
* *
*********************************************************************/
int Memu5()
{
system("cls");
system("color F9");
cout<<"\n\n\n\n\n\n\t*****************************************************************\t\n\n";
cout<<"\t\t\t【☆课程管理员☆】 \n\n";
cout<<" \t1.△新生注册△\t\t";
cout<<"2.△添加课程及相关信息△\n\n";
cout<<"\t3.△添加教师及相关信息△\t";
cout<<"4.△查看所有学生选课情况△\n\n";
cout<<"\t5.△修改密码△\t\t";
cout<<"6.△查看所有课程△\n\n";
cout<<"\t7.△显示所有学生△\t\t";
cout<<"8.△显示老师信息△\n\n";
cout<<"\t9.△切换用户△\t\t";
cout<<"0.△退出△";
cout<<"\n\n\t*****************************************************************\t\t";
cout<<"\n\t请选择:(0-9)";
int n;
n=shuzi();
while(n<=-1||n>10)
{
cout<<"你的输入有误,请重试\n请选择:(0-9):";
n=shuzi();
}
return n;
}
/*********************************************************************
* *
*********************************************************************/
void handle_Memu5()
{
for(;;)
{
switch(Memu5())
{
case 1:
{
system("cls");
int a=0;
CStudent stu[60];
char flag='Y';
while(toupper(flag)=='Y')
{
stu[a].Setsno("student.txt");
stu[a].Setsname();
stu[a].Setsex();
stu[a].Setbanji();
stu[a].Setzhuanye();
stu[a].Writef("student.txt");
a++;
cout<<"是否继续输入: Y(是)/其它(否)";
cin>>flag;
}
for(int i=0;i<a;)
stu[i++].Output();
cout<<"请按任意键继续";
getch();
system("cls");
break;
}
case 2:
{
system("cls");
int a=0;
CCourse course[60];
char flag='Y';
while(toupper(flag)=='Y')
{
course[a].Setcno();
course[a].Setcname();
course[a].Setxingzhi();
course[a].Setkeshi();
course[a].Settime();
course[a].Setaddress();
course[a].Setxuefen();
course[a].Writef("course.txt");
a++;
cout<<"是否继续输入: Y(是)/其它(否)";
cin>>flag;
}
for(int i=0;i<a;)
course[i++].Output();
cout<<"请按任意键继续";
getch();
system("cls");
break;
}
case 3:
{
system("cls");
int a=0;
CTeacher teacher[60];
char flag='Y';
while(toupper(flag)=='Y')
{
teacher[a].Settno();
teacher[a].Settname();
teacher[a].Setxi();
teacher[a].Setsex();
teacher[a].Setzhicheng();
teacher[a].Writef("teacher.txt");
a++;
cout<<"是否继续输入: Y(是)/其它(否)";
cin>>flag;
}
for(int i=0;i<a;i++)
teacher[i].Output();
system("cls");
break;
}
case 4:
{
system("cls");
CSubject subject;
subject.show4("subject.txt");
getch();
system("cls");
break;
}
case 5:
{
system("cls");
CLand land;
land.modifiy1("admin.txt");
cout<<"请按任意键继续";
getch();
system("cls");
break;
}
case 6:
{
system("cls");
CCourse course;
course.show2("course.txt");
cout<<"请按任意键继续";
getch();
system("cls");
break;
}
case 7:
{
system("cls");
CStudent stu;
stu.show("student.txt");
cout<<"请按任意键继续";
getch();
system("cls");
break;
}
case 8:
{
system("cls");
CTeacher teach;
teach.show3("teacher.txt");
cout<<"请按任意键继续";
getch();
system("cls");
break;
}
case 9:
{
system("cls");
handle_Memu1();
break;
}
case 0:
{
tuichu();
}
default:
system("cls");
cout<<"你的输入有误:";
break;
}
}
}
/*********************************************************************
* *
*********************************************************************/
int Memu4(void)
{
system("cls");
system("color F9");
cout<<"\n\n\n\n\n\n\t*****************************************************************\t\n\n";
cout<<"\t\t\t【☆教师授课管理☆】 \n\n";
cout<<" \t 1.△ △\t\t\t";
cout<<"2.△查看课程相关信息△\n\n";
cout<<"\t3.△查看本门课程选课人数△\t";
cout<<"4.△输入学生分数△\n\n";
cout<<"\t5.△修改密码△\t\t\t";
cout<<"6.△切换用户△\n\n";
cout<<"\t0.△退出△";
cout<<"\n\n\t*****************************************************************\t\t";
cout<<"\n\t请选择:(0-6)";
int n;
n=shuzi();
while(n<=-1||n>=9)
{
cout<<"你的输入有误,请重试\n请选择:(0-9):";
n=shuzi();
}
return n;
}
/*********************************************************************
* *
*********************************************************************/
void handle_Memu4()
{
for(;;)
{
switch(Memu4())
{
case 1:
{
system("cls");
cout<<"yes"<<endl;
cout<<"请按任意键继续";
getch();
system("cls");
break;
}
case 2:
{
system("cls");
cout<<"是否继续输入: 1(是)/其它(否)";
cout<<"请按任意键继续";
getch();
system("cls");
break;
}
case 3:
{
system("cls");
cout<<"是否继续输入: 1(是)/其它(否)";
cout<<"请按任意键继续";
getch();
system("cls");
break;
}
case 4:
{
system("cls");
cout<<"hao"<<endl;
cout<<"请按任意键继续";
getch();
system("cls");
break;
}
case 5:
{
system("cls");
CLand land;
land.modifiy2("tcode.txt");
getch();
system("cls");
break;
}
case 6:
{
system("cls");
handle_Memu1();
break;
}
case 0:
{
tuichu();
}
default:
system("cls");
cout<<"你的输入有误:";
break;
}
}
}
/*********************************************************************
* *
*********************************************************************/
int Memu1(void)
{
system("cls");
system("color F9");
cout<<"\n\n\n\n\t\t********************************************\n"
<<"\t\t* *\n"
<<"\t\t* 欢迎您使用学生选课系统 *\n"
<<"\t\t* *\n"
<<"\t\t* 本系统分为3个登陆端 *\n"
<<"\t\t* *\n"
<<"\t\t* 1.课程管理员登陆端 *\n"
<<"\t\t* *\n"
<<"\t\t* 2.学生选课登陆端 *\n"
<<"\t\t* *\n"
<<"\t\t* 3.教师登陆端 *\n"
<<"\t\t* *\n"
<<"\t\t* 0.退出系统 *\n"
<<"\t\t* *\n"
<<"\t\t********************************************\n"<<endl;
cout<<"\n\t请选择:(0-3)";
int n;
n=shuzi();
while(n<=-1||n>=4)
{
cout<<"您的输入有误,请重试\n请选择:(0-4):";
n=shuzi();
}
return n;
}
void handle_Memu1()
{
system("cls");
system("color F9");
int c=0,d=0;CLand land;
for(;;)
{
switch(Memu1())
{
case 1:
{
system("cls");
CLand land;
cout<<"\n\n\n\n\t\t\t欢迎您进入课程管理端\n";
cout<<"\n\t\t\t您的用户名为admin"<<endl;
land.Queryf2("admin.txt");
break;
}
case 2:
{
system("cls");
CLand land;
cout<<"\n\n\n\n\t\t\t欢迎你进入学生选课端\n";
cout<<"\n\t\t\t你的用户名为你的学号"<<endl;
land.Queryf("student.txt");
break;
}
case 3:
{
system("cls");
CLand land;
cout<<"\n\n\n\n\t\t\t欢迎您进入教师授课端\n";
cout<<"\n\t\t\t您的用户名为您的编号"<<endl;
land.Queryf1("teacher.txt");
break;
}
case 0:
{
tuichu();
}
default:
system("cls");
cout<<"您的输入有误,请重新输入";
break;
}
}
}
/*********************************************************************
* *
*********************************************************************/
void main(void)
{
Memu();
handle_Memu1();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -