#include "SeqList.h"
#include"menus.h"
FILE *stream;
int main()
{
char n='a';
SeqList temp;
menus();
cout<<"请选择功能(0--清屏)\t";
while(n!='9')
{
cin>>n;
switch ( n )
{
case '0':
{
system("cls");
menus();
break;
}
case '1' :
{
SeqList v;
cout<<"学生健康表(最多可存100人)已经生成了! ";
cout<<"请开始插入学生信息!\t"<<endl;
break;
}
case '2' :
{
int z;
T exp;
cout<<"你要插在第几位同学的后面呢?(范围0-"<<temp.Length()<< " ) ";
cin >> z ;
if(z < 0 || z > temp.Length () )
{
cout<<"你的输入不在0-"<<temp.Length()<< " 范围内,输入有误,请重新选择功能 "<<endl;
}
else
{
cout << " 请输入学号:"; cin >> exp.number;
cout << " 请输入姓名:"; cin >> exp.name;
cout << " 请输入出生(年:月:日) "; cin >> exp.dob;
cout << " 请输入性别(F/M):"; cin >> exp.sex;
cout << " 请输入生体状况:"; cin >> exp.condition;
temp.Insert(z,exp);
cout<<"******学生插入成功******"<<endl;
}
break ;
}
case '3' :
{
if(temp.Length()>0)
{
char z;
T exp;
cout<<"请输入你要删除的学生的学号:\t";
cin>> exp.number;
int i=temp.Search(exp);
if(temp.Search(exp)!=-1)
{
cout<<"*******你确定要删除"<<temp.data[i].name<<"吗?(确定y,取消n)******";
cin>>z;
if(z=='y')
{
temp.Remove(temp.Search(exp),exp);
cout<<"******该名学生已被删除。******"<<endl<<endl;
}
else
cout<<"学号"<<exp.number<<"的"<<temp.data[i].name<<"同学未被删除!";
}
else
cout<<"******该学号不存在!******"<<endl;
}
else
cout<<"健康表里空空如也,快去插入学生吧。"<<endl;
break;
}
case '4':
{
if(temp.Length()>0)
{
char z='a';
T exp;
cout<<"请输入你要修改的学生的学号:\t";
cin>> exp.number;
int i=temp.Search(exp);
if(i!=-1)
{
exp=temp.data[i];
while(z!='e')
{
cout<<"你要修改的是:"<<endl;
cout<<"学号(m),姓名(n),性别(s),出生日期(d),健康状况(c),结束(e)"<<endl;
cin>>z;
switch (z)
{
case 'm':
{
cout<<"请输入学号:";
cin>>exp.number;
break;
}
case 'n':
{
cout<<"请输入姓名:";
cin>>exp.name;
break;
}
case 'd':
{
cout<<"请输入出生日期(年/月/日):";
cin>>exp.dob;
break;
}
case 's':
{
cout<<"请输入性别:(F/M)";
cin>>exp.sex;
break;
}
case 'c':
{
cout<<"请输入健康状况:";
cin>>exp.condition;
break;
}
case 'e':
{break;}
default:
{
cout<<"输入有误!"<<endl;
break;
}
}
}
cout<<"*******你确定要修改"<<temp.data[i].name<<"吗?(确定y,取消n) ";
char k;
cin>>k;
if(k=='y') {temp.data[i]=exp;cout<<"修改成功。"<<endl;}
else cout<<"该生未被修改。"<<endl;
}
else
cout<<"******该学号不存在!******"<<endl;
}
else
cout<<"健康表里空空如也,快去插入学生吧。"<<endl;
break;
}
case '5':
{
if( (stream = fopen( "c:\\fread.txt", "r+t" )) != NULL )
{
int numread=0;
/* Attempt to read in 25 characters */
numread=fread( temp.data, sizeof( struct Student ), defaultSize, stream );
fclose( stream );
temp.last=numread-1;
cout<< "读取文件成功!"<< "读取学生" <<numread <<" 个!\n";
}
else
cout<< "由于某种原因,打不开文件\n" ;
break;
}
case '6':
{
if( (stream = fopen( "c:\\fread.txt", "w+t" )) != NULL )
{ int numwritten;
/* Write 25 characters to stream */
numwritten = fwrite( temp.data, sizeof( struct Student ), temp.Length(), stream );
cout<< "写入文件成功!"<<" 写入学生"<< numwritten <<"个!\n";
fclose( stream );
}
else
cout<< "由于某种原因,打不开文件\n";
break;
}
case '7':
{
T exp;
int i;
if(temp.Length()>0)
{
cout<<"请输入你要查找的学生的学号:\t";
cin>>exp.number;
if(temp.Search(exp)>-1)
{
i=temp.Search(exp);
cout << " 学号:"<<temp.data[i].number<<endl;
cout << " 姓名:"<< temp.data[i].name<<endl;
cout << " 出生(年/月/日) "<< temp.data[i].dob<<endl;
cout << " 性别:(F/M)"<<temp.data[i].sex<<endl;
cout << " 生体状况:"<< temp.data[i].condition<<endl;
}
else
cout << "学号为"<<exp.number<<"的学生未被录入系统"<<endl;
}
else
cout<<"健康表里空空如也,快去插入学生吧。"<<endl;
break;
}
case '8':
{
if(temp.Length()>0)
{
temp.Output();
}
else
cout<<"健康表里空空无也,快去插入学生吧。"<<endl;
break;}
case '9':
{ break;}
default:
{
cout<<"输入有误!"<<endl;
break;
}
}
cout<<"请选择功能(0--清屏)\t";
}
//getchar();
return 0;
}
shunxubiao.zip_shunxubiao
版权申诉
105 浏览量
2022-09-19
21:44:23
上传
评论
收藏 1.34MB ZIP 举报
![avatar](https://profile-avatar.csdnimg.cn/2416af5c19524431b870352d943af459_weixin_42659196.jpg!1)
周楷雯
- 粉丝: 82
- 资源: 1万+
最新资源
- Java项目-基于SSM+Vue的后勤管理系统的设计与实现(源码+数据库脚本+部署视频+代码讲解视频+全套软件)
- Quectel-EC2x&EG2x&EG9x&EM05-Series-QCFG-AT-Commands-Manual-V1.0
- 人工智能基于深度学习的农作物病虫害识别&防治系统项目(源码&教程)
- 数学建模企业退休职工养老金制度的改革(2)-PaperWord论文检测报告-20240626.zip
- Calculation.zip
- Java项目-基于SSM+Vue的视频点播系统的设计与实现(源码+数据库脚本+部署视频+代码讲解视频+全套软件)
- Python人工智能基于深度学习YOLOv7的农作物病虫害识别项目&防治系统(源码&教程)
- halcon算法总结下载
- 基于C语言的文件操作代码.zip
- Python基于YOLOv7的农作物病虫害识别项目&防治系统(源码&教程)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)