📄 operate.cpp
字号:
#include "OPERATE.H"
void OPERATE::Welcome()
{
cout<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<" 欢 迎 进 入 学 生 信 息 管 理 系 统 "<<endl<<endl<<endl<<endl;
cout<<" 制作人:陈泽焘"<<endl<<endl<<endl<<endl;
cout<<" 请输入密码或输入e退出:\n\n\n ";
}
void OPERATE::Display()
{
cout<<endl<<endl;
cout<<"*************************** 学生信息管理系统 **************************"<<endl;
cout<<" 1: 登记学生信息"<<endl;
cout<<" 2: 查询学生信息"<<endl;
cout<<" 3: 插入学生信息"<<endl;
cout<<" 4: 删除学生信息"<<endl;
cout<<" 5: 修改学生信息"<<endl;
cout<<" 6: 显示学生信息"<<endl;
cout<<" 7: 保存学生信息"<<endl;
cout<<" 0: 退出管理系统"<<endl;
cout<<"********************************************************************"<<endl;
}
void OPERATE::Circle()
{
LIST L1; //LIST 对象
char ch[20]; //存放用户选择信息
nodetype *p, *head; //定义结点类型的指针
int i; //存放节点序号
p = L1.Load(); //初始化:从外部文件读入数据创建链表
head = p;
while(1)
{
Display();//显示菜单
cout << endl << endl;
cout << "请选择操作: " << endl;
cin >> ch;
system("cls"); //用户输入完成后清屏,开始执行用户操作
if(L1.Check(ch, "1"))
{
system("cls");
cout << endl;
cout << "************** 登记学生信息 ******************" << endl;
cout << "**********************************************" << endl;
do{
p = L1.InsNode(0);
head = p;
cout << "输入学生个人信息: " << endl;
L1.EditPerson(p);
cout << "输入学生联系方式: " << endl;
L1.EditTelephone(p);
cout << "输入学生学科成绩: " << endl;
L1.EditScore(p);
cout << endl << "登记学生信息完成!" << endl;
cout << endl << "是否继续登记?(y/n)" << endl;
cin >> ch;
system("cls");
}while(L1.Check(ch,"Y") || L1.Check(ch,"y"));
}
if(L1.Check(ch, "2"))
{
system("cls");
cout << endl;
cout << "************** 查询学生信息 ******************" << endl;
cout << "**********************************************" << endl;
do{
cout << " 1.按学号查找" << endl;
cout << " 2.按姓名查找" << endl;
cout << "请选择操作: "<< endl;
char c[10];
cin >> c;
if(L1.Check(c,"1"))
{
L1.DispNum(); //输出所有学生学号
cout << endl << "请输入学生学号: "<< endl;
}
if(L1.Check(c,"2"))
{
L1.DispName();//输出所有学生姓名
cout << endl << "请输入学生姓名:" << endl;
}
cin >> ch;
p = L1.Find(ch);
if(p == NULL)
{
cout << endl << "没有该记录!" << endl;
}
else
{
L1.DispNode(p);
cout << endl << "查询学生信息完成!" << endl;
}
cout << "是否继续查询?(y/n)" << endl;
cin >> ch;
system("cls");
}while(L1.Check(ch,"y") || L1.Check(ch,"Y"));
}
if(L1.Check(ch, "3"))
{
system("cls");
do{
p=L1.InsNode(0);
head=p;
cout << endl;
cout << "************** 插入学生信息 ******************"<< endl;
cout << "**********************************************" << endl;
cout << "输入学生个人信息: " << endl;
L1.EditPerson(p);
cout << "输入学生联系方式: " << endl;
L1.EditTelephone(p);
cout << "输入学生学科成绩: " << endl;
L1.EditScore(p);
cout << endl << "插入学生信息完成!" << endl;
cout << endl << "是否继续插入?(y/n)" << endl;
cin >> ch;
system("cls");
}while(L1.Check(ch,"y") || L1.Check(ch,"Y"));
}
if(L1.Check(ch, "4"))
{
system("cls");
cout << endl;
cout << "************** 删除学生信息 ******************" << endl;
cout << "**********************************************" << endl;
do{
cout << " 1.按学号删除" << endl;
cout << " 2.按姓名删除" << endl;
cin >> ch;
if(L1.Check(ch,"1"))
{
L1.DispNum();
cout << endl << "输入学生学号:" << endl;
}
if(L1.Check(ch,"2"))
{
L1.DispName();
cout << endl << "输入学生姓名:" << endl;
}
cin>>ch;
i = L1.Find2(ch);
L1.DelNode(i);
cout << endl << "删除学生信息完成!" << endl;
cout << endl << "是否继续删除?(y/n)" << endl;
cin >> ch;
system("cls");
}while(L1.Check(ch,"y") || L1.Check(ch,"Y"));
}
if(L1.Check(ch, "5"))
{
system("cls");
cout << endl;
cout << "************** 修改学生信息 ******************" << endl;
do{
cout << "**********************************************" << endl;
cout << " 1.按学号修改" << endl;
cout << " 2.按姓名修改" << endl;
cin >> ch;
if(L1.Check(ch,"1"))
{
L1.DispNum();
cout << endl << "输入学生学号:" << endl;
}
if(L1.Check(ch,"2"))
{
L1.DispName();
cout << endl << "输入学生姓名:" << endl;
}
cin>>ch;
p = L1.Find(ch);
L1.DispNode(p);
if(p != NULL)
{
cout << endl << endl;
cout << "1: 修改个人信息" << endl;
cout << "2: 修改联系方式" << endl;
cout << "3: 修改学科成绩" << endl;
cout << "4: 修改所有信息" << endl;
cout << "请选择操作: "<<endl;
cin >> ch;
system("cls");
if(L1.Check(ch, "1"))
{
cout<<endl;
cout<<"************** 修改个人信息 ******************"<<endl;
L1.EditPerson(p);
cout << endl << "修改个人信息完成!" << endl;
}
else if(L1.Check(ch, "2"))
{
cout<<endl;
cout<<"************** 修改联系方式 ******************"<<endl;
L1.EditTelephone(p);
cout << endl << "修改联系方式完成!" << endl;
}
else if(L1.Check(ch, "3"))
{
cout<<endl;
cout<<"************** 修改学科成绩 ******************"<<endl;
L1.EditScore2(p);
cout << endl << "修改学科成绩完成!" << endl;
}
else if(L1.Check(ch, "4"))
{
cout << endl;
cout<<"************** 修改所有信息 ******************"<<endl;
L1.EditPerson(p);
L1.EditTelephone(p);
L1.EditScore(p);
cout << endl << "修改学生信息完成!" << endl;
}
}
else
cout << endl << "没有该记录!" << endl;
cout << endl << "是否继续修改?(y/n)" << endl;
cin >> ch;
system("cls");
}while(L1.Check(ch, "y") || L1.Check(ch, "Y"));
}
if(L1.Check(ch,"6"))
{
system("cls");
cout << endl;
cout << "************** 显示学生信息 ******************" << endl;
cout << "**********************************************" << endl;
cout << " 1.显示所有学生姓名" << endl;
cout << " 2.显示所有学生信息" << endl;
cin >> ch;
system("cls");
if(L1.Check(ch,"1"))
{
L1.DispName();
}
if(L1.Check(ch,"2"))
{
L1.DisAll();
}
}
if(L1.Check(ch, "7"))
{
FILE *fp;
if((fp=fopen("student.txt", "w"))==NULL)
{
cout<<"打开文件失败"<<endl;
return;
}
int i;
char t[255];
//将 L1.Listlen() 赋予字符串中的数字
sprintf(t, "The Length Of Link: %d\n", L1.Listlen());
fputs(t, fp);
strcpy(t, "\n");
fputs(t, fp);
p = L1.FindNode(1); //将链表头指针赋予 p
for(i = 0; i < L1.Listlen(); i ++)
{
fputs(p->st.pe.name, fp); //输出姓名
fputs(p->st.pe.num, fp); //输出学号
fputs(p->st.pe.sex, fp); //输出性别
fputs(p->st.pe.birthday, fp); //输出生日
fputs(p->st.pe.nation, fp); //输出民族
fputs(p->st.pe.college, fp); //输出学院
fputs(p->st.pe.clas, fp); //输出班级
fputs(p->st.te.phone, fp); //输出手机号码
fputs(p->st.te.tel, fp); //输出电话号码
fputs(p->st.te.address, fp); //输出家庭地址
fputs(p->st.sc.english, fp); //输出英语成绩
fputs(p->st.sc.chiness, fp); //输出语文成绩
fputs(p->st.sc.math, fp); //输出数学成绩
fputs(p->st.sc.pe, fp); //输出体育成绩
fputs(t, fp);
p=p->next;
}
p=head;
fclose(fp);
cout << endl << "保存数据完成!" << endl;
}
if(L1.Check(ch,"0"))
{
cout << endl << "谢谢使用!" << endl;
cout << "如在使用中有什么问题或建议请联系:" << endl;
cout << "QQ:251783275" << endl;
cout << "E-mail:czt19870329@sina.com" << endl << endl;
return;
}
}
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -