#include<iostream>
#include<string>
#include<fstream>
#include<iomanip>
const int TMAX=50;
using namespace std;
class Student //对于基类的定义
{
public:
int num; //公用数据成员用于记录类成员的编号
string name;
string sex;
int age;
public:
Student(int n=0,string nm="",string s="",int a=0):num(n),name(nm),sex(s),age(a){};
virtual void Input(){};
virtual void Output(){};
int GetNum(){return num;}//公有数据成员函数用于获得成员编号
string GetName(){return name;}//公有数据成员函数用于获得成员姓名
};
class Pupil:public Student//对小学生派生类的定义
{
public:
string Chinese;//公有数据成员用于记录小学生的语文成绩
string Math;//公有数据成员用于记录类成员的数学成绩
int choice2;//公有数据成员用于选择类成员的性别
public:
Pupil(int n=0,string nm="",string s="男",int a=0,string l="",string z="")
:Student(n,nm,s,a),Chinese(l),Math(z){};
void Input()//成员函数用于输入成员信息
{
cout<<"input the num"<<endl;
cin>>num;
cout<<"input the name"<<endl;
cin>>name;
cout<<"input the sex";
cout<<"(1.男 2.女)"<<endl;
cout<<"请输入你的选择"<<endl;
cin>>choice2;
switch(choice2)
{
case 1:sex="男";break;
case 2:sex="女";break;
default:cout<<"输入错误。"<<endl;break;
}
cout<<"input the age"<<endl;
cin>>age;
cout<<"input the Chinese"<<endl;
cin>>Chinese;
cout<<"input the Math"<<endl;
cin>>Math;
}
void Output()//成员函数用于输出成员信息
{
cout<<setw(10)<<num
<<setw(10)<<name
<<setw(10)<<sex
<<setw(10)<<age
<<setw(10)<<Chinese
<<setw(10)<<Math
<<endl;
}
};
class Middle:virtual public Student//对于中学生派生类的定义
{
public:
string geography;//公有数据成员用于记录类成员的地理成绩
string history;//公有数据成员用于记录类成员的历史成绩
string addrres;//公有数据成员用于记录类成员的家庭住址
int choice2;//公有数据成员用于选择类成员的性别
public:
Middle(int n=0,string nm="",string s="男",int a=0,string ge="地理",string hi="",string ad="")
:Student(n,nm,s,a),geography(ge),history(hi),addrres(ad){};
void Input()//成员函数用于输入成员信息
{
cout<<"input the num"<<endl;
cin>>num;
cout<<"input the name"<<endl;
cin>>name;
cout<<"input the sex";
cout<<"(1.男 2.女)"<<endl;
cout<<"请输入你的选择"<<endl;
cin>>choice2;
switch(choice2)
{
case 1:sex="男";break;
case 2:sex="女";break;
default:cout<<"输入错误。"<<endl;break;
}
cout<<"input the age"<<endl;
cin>>age;
cout<<"input the geography"<<endl;
cin>>geography;
cout<<"input the history"<<endl;
cin>>history;
cout<<"input the addrres"<<endl;
cin>>addrres;
}
void Output()//成员函数用于输出成员信息
{
cout<<setw(10)<<num
<<setw(10)<<name
<<setw(10)<<sex
<<setw(10)<<age
<<setw(10)<<geography
<<setw(10)<<history
<<setw(10)<<addrres
<<endl;
}
};
class College:virtual public Student//对于大学生派生类的定义
{
public:
string speciailty;//公有数据成员用于记录类成员的专业
string telephone;//公有数据成员用于记录类成员的联系方式
int choice2;// 公有数据成员用于选择成员的性别
public:
College(int n=0,string nm="",string s="男",int a=0,string speciailty="",string te="")
:Student(n,nm,s,a),speciailty(s),telephone(te){};
void Input()//成员函数用于输入成员信息
{
cout<<"input the num"<<endl;
cin>>num;
cout<<"input the name"<<endl;
cin>>name;
cout<<"input the sex";
cout<<"(1.男 2.女)"<<endl;
cout<<"请输入你的选择"<<endl;
cin>>choice2;
switch(choice2)
{
case 1:sex="男";break;
case 2:sex="女";break;
default:cout<<"输入错误。"<<endl;break;
}
cout<<"input the age"<<endl;
cin>>age;
cout<<"input the speciailty"<<endl;
cin>>speciailty;
cout<<"input the telephone"<<endl;
cin>>telephone;
}
void Output()
{
cout<<setw(10)<<num
<<setw(10)<<name
<<setw(10)<<sex
<<setw(10)<<age
<<setw(10)<<speciailty
<<setw(10)<<telephone
<<endl;
}
};
class Pup_Manage
{
Pupil Mid[TMAX]; //TMAX为常量,为数组中可存储的中学生记录的最大数;
int top; //top表示当前系统中存储的记录个数;
public:
Pup_Manage(){top=0;} //初始时记录的个数为0,所以设置top=0;
void Add(); //实现该类记录的添加;
void Show(); //实现该类所有记录的显示;
void Search(); //实现该类记录的查询;
void Edit(); //实现该类记录的修改;
void Delete(); //实现该类记录的删除;
void Total(); //实现该类记录的统计;
void Save(); //将该类记录保存到文件;
void Read(); //可从文件中将记录读取到该类的数组中;
};
void Pup_Manage::Add()//函数的实现进行添加功能
{
if(top>=TMAX)
{
cout<<"用户已满"<<endl;
return;
}
Pupil t;
cout<<"输入新添加的学生的信息"<<endl;
t.Input();
for(int i=0;i<top;i++)
if (t.GetNum()==Mid[i].GetNum())
{
cout<<"该编号的学生已存在"<<endl;
return;
}
Mid[top]=t;
top=top+1;
cout<<"添加成功!"<<endl;
}
void Pup_Manage::Show()//显示功能:可显示当前系统中所有记录,每条记录占据一行。
{
if(top==0)
{
cout<<"无数据!"<<endl;
return;
}
cout<<setw(10)<<"编号"
<<setw(10)<<"姓名"
<<setw(10)<<"性别"
<<setw(10)<<"年龄"
<<setw(10)<<"语文"
<<setw(10)<<"数学"
<<endl;
for(int i=0;i<top;i++)
Mid[i].Output();
}
void Pup_Manage::Search()//查询功能:可根据编号、姓名等信息对已添加的记录进行查询,如果未找到,给出相应的提示信息,如果找到,则显示相应的记录信息。
{
if(top==0)
{
cout<<"当前系统中没有存储记录"<<endl;
return;
}
int choice;
cout<<"请选择查找方式:1.按编号查找 2.按姓名查找."<<endl;
cin>>choice;
switch(choice)
{
case 1:{
cout<<"请输入要查找的编号:"<<endl;
int num;
cin>>num;
for(int i=0;i<top;i++)
{
if(Mid[i].GetNum()==num)
{
Mid[i].Output();
return;
}
}
cout<<"查无此人!"<<endl;
}break;
case 2:{
cout<<"请输入要查找的姓名"<<endl;
string name;
cin>>name;
for(int i=0;i<top;i++)
{
if(Mid[i].GetName()==name)
{
Mid[i].Output();
}
}
for( i=0;i<top;i++)
if(Mid[i].GetName()==name)
return;
cout<<"查无此人!"<<endl;
}break;
default :cout<<"无此选项!请重试!"<<endl;break;
}
}
void Pup_Manage::Edit()
{
if(top==0)
{
cout<<"当前系统中没有存储记录!"<<endl;
return;
}
int num;
cout<<"请输入要查找的学生编号:"<<endl;
cin>>num;
for(int i=0;i<top;i++)
{
if(Mid[i].GetNum()==num)
{
cout<<"请对这位小学生的信息进行修改:"<<endl;
Mid[i].Input();
cout<<"修改成功"<<endl;return;
}
}
cout<<"查无此人"<<endl;
}
void Pup_Manage::Delete()//删除功能:主要实现对已添加的人员记录进行删除。如果当前系统中没有相应的人员记录,则提示"记录为空!"并返回操作;否则,输入要删除的人员的编号或姓名,根据所输入的信息删除该人员记录,如果没有找到该人员信息,则提示相应的记录不存在。
{
if(top==0)
{
cout<<"当前系统中没有存储记录!"<<endl;
return;
}
cout<<"1、按编号查找删除 2、按姓名查找删除"<<endl;
int choice;
cin>>choice;
switch(choice)
{
case 1:
{
cout<<"请输入编号:";
int num;
cin>>num;
for(int i=0;i<top;i++)
{
if(num==Mid[i].num)
{
cout<<"是否确认删除? 1、是 2、否 "<<endl;
int choice;
cin>>choice;
switch(choice)
{
case 1:
{
for(int j=i;j<top-1;j++)
Mid[j]=Mid[j+1];
cout<<"删除成功!"<<endl;
top--;
};break;
case 2:return;
default:cout<<"无此项,失败!"<<endl;break;
}return;
}
}
cout<<"无此人!"<<endl;
} ;break;
case 2:
{
cout<<"请输入姓名:";
string name;
cin>>name;
for(int i=0;i<top;i++)
{
if(name==Mid[i].name)
{
cout<<"是否确认删除? 1、是 2、否 "<<endl;
int choice;
cin>>choice;
switch
没有合适的资源?快使用搜索试试~ 我知道了~
学生信息管理系统,实现学生信息包括:学号、姓名、性别、年龄、班级等信息。
共1个文件
cpp:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 4 下载量 141 浏览量
2022-07-01
16:33:57
上传
评论 6
收藏 4KB RAR 举报
温馨提示
学生信息管理系统,实现学生信息包括:学号、姓名、性别、年龄、班级等信息。 小学生除了包括学生所有信息外,还包括英语、数学和语文成绩。 中学生除了包括小学生所有信息外,还包括地理、历史成绩、家庭住址等信息。 大学生除了包括学生所有信息外,还包括专业、家庭地址、联系方式等信息。 2、功能要求 (1)添加功能:(2)查询功能:(3)显示功能:(4)编辑功能:(5)删除功能:(6)统计功能:(7)保存功能:(8)读取功能:
资源推荐
资源详情
资源评论
收起资源包目录
1032716.rar (1个子文件)
1032716.cpp 24KB
新建文件夹
共 1 条
- 1
N201871643
- 粉丝: 628
- 资源: 2243
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页