C++学生档案管理系统
shaolong_CHEN 人气:0课题描述:
1.为学生档案管理人员编写一个学生档案管理系统 ,用菜单选择方式完成下列功能:
2.学生档案信息添加:包括学号、姓名、性别、出生日期、学院、专业、班级、SFZ号、政治面貌、籍贯、家庭住址、电话等。
3.学生档案信息查询:分别按学号、姓名、性别、学院、专业、班级、政治面貌、籍贯等进行查询。
4.学生档案信息的修改、删除:按姓名+学号进行学生档案信息的修改和删除。
系统简要分析:
1.学生档案管理系主要功能为:添加学生档案信息,如:学号,姓名,出生日期,学院,专业,班级,SFZ号码,籍贯,家庭地址,电话等信息,并可以编辑学生档案信息,方便修改删减,还有按照一定要求排序学生档案。
2.本系统将创建一个学生档案管理系统的类,添加一些学生档案的属性和行为,进行学生档案信息的输入和输出。
3.该档案管理系统的修改和删除功能,分别可以由姓名和学号先进行查找,然后输出要修改的学生信息,然后系统会提供相应的提示,让你选要修改的学生信息中具体的信息,如单独修改学号或专业信息等。本系统的插入和删除功能,都运用了单链表易于删除和查找的功能特点。
4.系统具体操作功能如下,首先程序运行后,显示菜单功能列表。然后输入者根据菜单选项进行输入操作,可以添加自己的个人信息,修改信息,查询所要的信息。然后档案管理员可以在后期查找所需学生信息,进行输出修改。
源代码:
#include<iostream> #include <string> using namespace std; class Student { private: string number;//学号 string name;//名字 string grade;//班级 string sex;//性别 int telephone;//手机号码 int identify;//SFZ号码 string major;//专业 string political;//政治面貌 string address;//家庭地址 string nation;//籍贯 public: Student* next;//next指向下一个学生,构成链表 Student() { next = NULL; } Student(string n, string g, string num, string s, int tp, int i, string m, string p,string na,string a) { name = n; grade = g; number = num; sex = s; telephone = tp; identify = i; major = m; political = p; nation = na; address = a; next = NULL; };//构造函数 string getname() { return name; }//名字 string getgrade() { return grade; }//班别 string getnum() { return number; }//学号 string gets() { return sex; }//性别 int gettp() { return telephone; }// int geti() { return identify; }// string getm() { return major; } string getp() { return political; } string getna() { return nation; } string geta() { return address; } void setnum(string num) { number = num; }//修改学号 void setgrade(string g) { grade = g; }//修改班级 void setname(string n) { name = n; }//修改名字 void sets(string s) { sex = s; }//修改性别 void settp(int tp) { telephone = tp; }//修改手机号码 void seti(int i) { identify = i; }//修改SFZ void setm(string m) { major = m; } void setp(string p) { political = p; } void setna(string na) {nation = na;} void seta(string a) { address = a; } }; class Operation { private: Student* head; public: Operation() { head = new Student; } void Menu();//菜单 void Insert();//插入 void Search();//查找 void Remove();//修改 void Delete();//删除 void Print();//输出 }; void Operation::Menu() { cout << "*******************************************************************************************" << endl; cout << "------------------------- xxx大学学生档案管理系统 -------------------------" << endl; cout << "------------------------- *********************** -------------------------" << endl; cout << "------------------------- 1.增加学生信息 -------------------------" << endl; cout << "------------------------- 2.显示学生信息 -------------------------" << endl; cout << "------------------------- 3.查找学生信息 -------------------------" << endl; cout << "------------------------- 4.删除学生信息 -------------------------" << endl; cout << "------------------------- 5.修改学生信息 -------------------------" << endl; cout << "------------------------- 6.安全退出系统 -------------------------" << endl; } void Operation::Insert() //插入 { string name;//名字 string grade;//班级 string number;//学号 string sex;//性别 int telephone;//手机号 int identify;//SFZ号码 string major; string political; string nation; string address; Student* p = NULL; cout << "请输入要添加学生的信息:" << endl; cout << "请输入姓名:"; cin >> name; cout << endl; cout << "请输入班级:"; cin >> grade; cout << endl; cout << "请输入学号:"; cin >> number; cout << endl; cout << "请输入性别:"; cin >> sex; cout << endl; cout << "手机号码:"; cin >> telephone; cout << endl; cout << "SFZ号码:"; cin >> identify; cout << endl; cout << "专业:"; cin >> major; cout << endl; cout << "政治面貌:"; cin >> political; cout << endl; cout << "籍贯:"; cin >> nation; cout << endl; cout << "家庭地址:"; cin >> address; cout << endl; Student* s = new Student(name, grade, number, sex, telephone, identify, major, political, nation, address); p = head; while (p->next != NULL && p->getnum() < s->getnum()) { p = p->next; } s->next = p->next; p->next = s; } void Operation::Delete()//删除 { string name; Student* p = head->next, * q = head; cout << "请输入要删除学生信息的姓名:" << endl; cin >> name; while (p != NULL) { if (p->getname() == name) { q->next = p->next; delete p; break; } p = p->next; q = q->next; } if (p != NULL) { cout << "删除成功!" << endl; } if (p == NULL) { cout << "\t\t没有找到!" << endl; } } void Operation::Search()//查询 { Student* p = NULL; cout << "\n** 查询学生信息 **\n" << endl; cout << "请输入查询方式:" << endl; cout << "1.按学号查询" << endl; cout << "2.按姓名查询" << endl; cout << "3.返回" << endl; char c; cin >> c; switch (c) { case '1': {string n; cout << "请输入你要查询的学生的学号" << endl; cin >> n; for (p = head; p != NULL; p = p->next) { if (p->getnum() == n) { cout << "姓名:" << p->getname() << endl << "班别:" << p->getgrade() << endl << "学号:" << p->getnum() << endl << "性别:" << p->getgrade() << endl << "电话号码:" << p->gettp() << endl << "SFZ号码:" << p->geti() << endl << "专业:" << p->getm() << endl << "政治面貌:" << p->getp() << endl << "籍贯:" << p->getna() << endl << "家庭地址:" << p->geta() << endl; } } break; } case '2': { string name; cout << "请输入你要查询的学生姓名" << endl; cin >> name; for (p = head; p != NULL; p = p->next) { if (name == p->getname()) { cout << "姓名:" << p->getname() << endl << "班级:" << p->getgrade() << endl << "学号:" << p->getnum() << endl << "性别:" << p->gets() << endl << "手机号码:" << p->gettp() << endl << "SFZ号码:" << p->geti() << endl << "专业:" << p->getm() << endl << "政治面貌:" << p->getp() << endl << "籍贯:" << p->getna() << endl << "家庭地址:" << p->geta() << endl; } } break; } case '3': return; } } void Operation::Print() //输出 { Student* p; cout << "姓名" << "\t班级" << "\t学号" << "\t性别" << "\t手机号码" << "\tSFZ号码" << "\t专业" << "\t政治面貌" << "\t籍贯" << "\t地址" << endl; for (p = head->next; p != NULL; p = p->next) cout << p->getname() << "\t" << p->getgrade() << "\t" << p->getnum() << "\t" << p->gets() << "\t" << p->gettp() << "\t\t" << p->geti() << "\t\t" << p->getm() << "\t" << p->getp() << "\t\t" << p->getna() << "\t" << p->geta() << endl; } void Operation::Remove() //修改 { string n;//修改项 string number;//学号 string grade;//班级 string name;//名字 string sex;//性别 int telephone;//手机号码 int identity;//SFZ号码 int birth;//出生日期 string major; string political; string nation; string address; cout << "请输入你要修改的学生姓名" << endl; cin >> n; Student* p; for (p = head->next; p != NULL; p = p->next) if (p->getname() == n) { cout << "请选择您要修改的信息项:" << endl; cout << "1、学号,2、班别,3、姓名,4、性别,5、手机号码,6、SFZ号码,7、出生日期,8、专业,9、政治面貌,10、籍贯,11、家庭地址。" << endl; int in; cin >> in; switch (in) { case 1: cout << p->getnum() << "修改为:" << endl; cin >> number; p->setnum(number); break; case 2: cout << p->getgrade() << "修改为:" << endl; cin >> grade; p->setgrade(grade); break; case 3: cout << p->getname() << "修改为:" << endl; cin >> name; p->setname(name); break; case 4: cout << p->gets() << "修改为:" << endl; cin >> sex; p->sets(sex); break; case 5: cout << p->gettp() << "修改为:" << endl; cin >> telephone; p->settp(telephone); break; case 6: cout << p->geti() << "修改为:" << endl; cin >> identity; p->seti(identity); break; case 8: cout << p->getm() << "修改为:" << endl; cin >> major; p->setm(major); break; case 9: cout << p->getp() << "修改为:" << endl; cin >> political; p->setp(political); break; case 10: cout << p->getna() << "修改为:" << endl; cin >> nation; p->setna(nation); break; case 11: cout << p->geta() << "修改为:" << endl; cin >> birth; p->seta(address); break; default: cout << "输入错误!" << endl; break; } } } int main() { Operation O; O.Menu(); while (1) { int n; cout << "\n\t\t\n\t\t请选择:"; cin >> n; switch (n) { case 1://增加 O.Insert(); break; case 2://显示 O.Print(); break; case 3://查找 O.Search(); break; case 4://删除 O.Delete(); break; case 5://修改 O.Remove(); break; case 6: cout << "******************************" << "\n感谢您的使用!\n" << "******************************" << endl; exit(0); } } return 0; }
效果演示:
1.主函数样式
2.输入输出信息
3.查询信息
4.删除修改信息
5.退出系统
加载全部内容