学生信息管理系统C++代码要点.pdf

上传人:tbuqq 文档编号:5207906 上传时间:2020-02-21 格式:PDF 页数:13 大小:798.58KB
返回 下载 相关 举报
学生信息管理系统C++代码要点.pdf_第1页
第1页 / 共13页
学生信息管理系统C++代码要点.pdf_第2页
第2页 / 共13页
学生信息管理系统C++代码要点.pdf_第3页
第3页 / 共13页
学生信息管理系统C++代码要点.pdf_第4页
第4页 / 共13页
学生信息管理系统C++代码要点.pdf_第5页
第5页 / 共13页
点击查看更多>>
资源描述

《学生信息管理系统C++代码要点.pdf》由会员分享,可在线阅读,更多相关《学生信息管理系统C++代码要点.pdf(13页珍藏版)》请在三一文库上搜索。

1、1. 程序执行后的部分效果 1.1 项目主菜单效果图 1.2 初始化信息,第一次对信息的录入 1.3 添加学生信息 1.4 删除某学生信息 1.5 修改某学生信息 1.6 查询某学生信息 1.7 显示全部学生信息 源代码 : /* 把 StudentData.cpp(源代码 ) 和 student.txt(数据存放处 ) 放在同 一个文件夹下 */ #include #include #include #include #include using namespace std; / 最多提供 50个学生的数据,可根据需要进行更改 const int MAX = 50; int count =

2、0; / 用来统计学生人数 class Student public: void Set(); / 初始化信息,第一次对信息的录入 void Add(); / 添加学生信息 / 从磁盘读取数据以便进行 数据的操作,方便再重写进磁盘 friend void Read(string no,string name,string sex,string special,string clas); int Judge(string num); / 判断 num 是否在学生信息数据库中 (注意它有一个参数,并且有一个int型的返回值) void Delete(); / 删除某学生信息 void Change

3、(); / 修改某学生信息 void Search(); / 查询某学生信息 void Display(); / 显示全部学生信息 private: string m_no; string m_name; string m_sex; /m_ 指的是成员变量( member ) string m_special; string m_clas; ; void Student:Set() string no, name, sex, special, clas; ofstream outfile(“student.txt“); / 打开文件 if(!outfile) cerrno; if(no = “

4、0“) break; / 当输入的学号是 0 时,停止录 入 cinnamesexspecialclas; count+; m_no = no; outfilenonamesexspecialclas; m_no = no; outfilenoinameisexispecialiclasi; infile.close(); / 判断某学号的学生是否在数据库中 int Student:Judge(string num) string noMAX, nameMAX, sexMAX, specialMAX, clasMAX; Read(no, name, sex, special, clas); /

5、 调 用 Read() 函 数,获取数据,以便等下进行相关数据的判断 for(int i=0; inum; int k = Judge(num); / 定义一个 k 来接收 Judge() 的返 回值,等下用来判断该num是否存在 if(k != -1) / 如果 k 不等于 -1 , 表示要删除的学生存在 ofstream outfile(“student.txt“); if(!outfile) cerrnum; int k = Judge(num); if(k != -1) Read(no, name, sex, special, clas); / 读取学生所 有数据, coutnokna

6、meksexkspecialkclask; / 把下标是 k 的学生进行修改 ofstream outfile(“student.txt“,ios:out); if(!outfile) cerrnum; int k = Judge(num); if(k != -1) / 找到该学生就打印出其信息 coutchoice; switch(choice) case 1: s.Set(); break; case 2: s.Add(); break; case 3: s.Delete(); break; case 4: s.Change(); break; case 5: s.Search(); break; case 6: s.Display(); break; case 0: break; default: cout“ 你的选择有误 ! 请重新选择 !“endl; break; return 0;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1