- 1、本文档共10页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
题目 学生健康情况管理系统
【问题描述】
实现学生健康情况管理的几个操作功能(新建、插入、删除、从文件读取、写入文件和查询、屏幕输出等功能)。健康表中学生的信息有学号、姓名、出生日期、性别、身体状况等。
【实验内容】
必做内容
利用顺序存储结构来实现
系统的菜单功能项如下:
1------新建学生健康表
2------向学生健康表插入学生信息
3------在健康表删除学生信息
4------从文件中读取健康表信息
5------向文件写入学生健康表信息
6------在健康表中查询学生信息(按学生学号来进行查找)
7------在屏幕中输出全部学生信息
8-----退出
程序如下:
#include iostream
#include fstream
using namespace std;
/*
* 学生结点的设置,包含学号stuID,姓名name,出生日期BirthOfDate,
性别sex(B、G),健康状况(A,B,C)
*/
struct birthday //出生日期
{
unsigned short day;
unsigned short month;
unsigned short year;
};
struct Sstudent //一个学生的基本信息
{
char stuID[12]; //学号
char name[12]; //名字
struct birthday bd; //出生日期
char sex[4]; //性别
char healthcase[10]; //健康情况
Sstudent(){}
void input(); //输入学生的基本信息
void output(); //输出学生的基本信息
void operator =(Sstudent s);
bool operator (Sstudent s);
bool operator == (Sstudent s);
bool operator (Sstudent s);
};
void Sstudent::input() //输入一个学生的信息
{
cout请输入学生信息:endl;
cout请输入学生的学号:;
cinstuID;
cout请输入学生的名字:;
cinname;
cout请输入学生的性别:;
cinsex;
cout请输入学生生日的日期(年、月、日):;
cinbd.yearbd.monthbd.day;
cout请输入学生的健康情况(良好或差):;
cinhealthcase;
coutendl;
}
void Sstudent::output() //输出一个学生的信息
{
cout学号: stuIDendl
姓名: nameendl
性别: sexendl
生日: bd.year/bd.month/bd.dayendl
健康情况: healthcaseendlendl;
}
void Sstudent::operator =(Sstudent s)
{
strcpy(stuID,s.stuID);
strcpy(name,s.name);
strcpy(sex,s.sex);
bd.year=s.bd.year;
bd.month=s.bd.month;
bd.day=s.bd.day;
strcpy(healthcase,s.healthcase);
}
bool Sstudent::operator (Sstudent s)
{
if(strcmp(stuID,s.stuID) == -1) //若number 小于 s.number
return true;
else
return false;
}
bool Sstudent::operator == (Sstudent s)
{
if( !strcmp(name,s.name) ) //若name 等于 s.number
if( !strcmp(stuID,s.stuID) ) //若num 等于 s.number
return true;
return false;
}
bool Sstudent::operator (Sstudent s)
{
文档评论(0)