C++2005 写的学生管理系统,不用MFC界面,要有管理员和学生两种身份登陆
2条回答 默认 最新
- devmiao 2014-12-06 14:21关注
#include
#include
#include
using namespace std;
typedef struct stu//定义一个结构体作为类的私有成员
{
int num;
string name;
};
class student //学生类为基类
{
protected:
stu a[100];
int i, n;
static int d;//计算输入学生总数
public:
student();//构造函数
char menu();//菜单界面
void activity();//进行各种操作的一个平台
void input();//输入函数
void display(); //显示函数
void append();//追加函数
void searach();//查找函数
};
class teacher:public student
{
public:
teacher():student(){};
//下面几个函数是对其他函数的重定义
char menu();//增加了其他函数的菜单界面
void activity();//进行各种操作的一个平台
void mod();//修改函数
void shanchu();//删除函数
};
int student::d=0;//计数器赋值为0
student::student()//构造函数
{
cout<<"****welcome to the student`s information systerm ****"<<endl;
}
char student::menu()//学生菜单界面
{
char m;
cout<<"*********1:input the student`s information***********"<<endl;
cout<<"*********2:display the student`s information*********"<<endl;
cout<<"*********3:append the student`s information**********"<<endl;
cout<<"*********4:searach the student`s information*********"<<endl;
cout<<"*****************0:quit the systerm*****************"<<endl;
cout<<"*****************please input one number![ ]\b\b\b\b";
cin>>m;
return m;
}
char teacher::menu()//教师菜单界面
{
char m;
cout<<"*********1:input the student`s information***********"<<endl;
cout<<"*********2:display the student`s information*********"<<endl;
cout<<"*********3:append the student`s information**********"<<endl;
cout<<"*********4:searach the student`s information*********"<<endl;
cout<<"*********5:mod the student`s information*************"<<endl;
cout<<"*********6:shanchu the student`s information*********"<<endl;
cout<<"*****************0:quit the systerm*****************"<<endl;
cout<<"*****************please input one number![ ]\b\b\b\b";
cin>>m;
return m;
}
void student::activity()//学生各种操作界面
{
char k;
while(1)
{
k=menu(); switch (k)
{
case '1':input();break;
case '2':display();break;
case '3':append();break; case '4':searach();break; case '0':cout<<"**********thanks you !bye bye**********!"<<endl;return ; default:cout<<"you are wrong!"<<endl; }
}
}
void teacher::activity()//教师各种操作界面
{
char k;
while(1)
{
k=menu(); switch (k)
{
case '1':input();break;
case '2':display();break;
case '3':append();break; case '4':searach();break; case '5':mod();break; case '6':shanchu();break; case '0':cout<<"**********thanks you !bye bye**********!"<<endl;return ; default:cout<<"you are wrong!"<<endl; }
}
}
void student:: input()//输入函数
{
cout<<"please input one counter about student numbers!"<<endl;
cin>>n;
for(i=0;i<n;i++)
{ cout<<"the student`s num is :"<<endl;
cin>>a[i].num; cout<<"the student`s name is : "<<endl; cin>>a[i].name; d++;
}
cout<<"the work is done! "<<endl;
display();
}
void student::display()//显示函数
{
cout<<"the student`s num : name"<<endl; for(i=0;i<d;i++) { cout<<" "<<a[i].num<<" "<<a[i].name<<endl; }
}
void student::append()//追加
{
int m;
cout<<"please input the counter numbers for append student~s information!"<<endl;
cin>>m;
for(i=n;i<n+m;i++)
{
cout<<"the student`s num is :"<<endl; cin>>a[i].num; cout<<"the student`s name is : "<<endl; cin>>a[i].name; d++;
}
cout<<"the work is done! "<<endl;
display();
}
void student::searach()//查找
{
int nu,g=0; cout<<"please the student`s num"<<endl; cin>>nu; for(i=0;i<d;i++) { if(a[i].num==nu) { cout<<"the student`s num : name"<<endl; cout<<" "<<a[i].num<<" "<<a[i].name<<endl; g=1; } } if(g==0) cout<<"not found the student`s information!"<<endl; cout<<"the work is done!"<<endl;
}
void teacher::mod()//修改
{
int nu; cout<<"please input the student`s num"<<endl; cin>>nu; for(i=0;i<d;i++) { if(nu==a[i].num) { cout<<"the student`s num is :"<<endl; cin>>a[i].num; cout<<"the student`s name is : "<<endl; cin>>a[i].name; } }
cout<<"the work is done! "<<d<<endl;
display();
}
void teacher::shanchu()//删除函数
{ int nu,s=-1;
cout<<"please input the student`s number!";
cin>>nu;
for(i=0;i<=d;i++)
{
if(nu==a[i].num)
{s=i; for(i=s+1;i<d;i++) { a[i-1].num=a[i].num; a[i-1].name=a[i].name; } d--; }
}
if(s==-1)
cout<<"not found the student`s information!"<<endl;
cout<<"the work is done! "<<endl;
display();
}
void stu()//一级菜单,进入学生操作界面
{
student stud; stud.activity();
}
void teach()//一级菜单,进入教师操作界面
{
teacher t;
t.activity();
}
int main()
{
char c;
cout<<"&&&&&&welcome to the student`s information systerm&&&&&&"<<endl;
cout<<"&&&&&&&&&&&&&&&s: 学生身份&&&&&&&&&&&&&&&"<<endl;
cout<<"&&&&&&&&&&&&&&&t: 教师身份&&&&&&&&&&&&&&&"<<endl;
cout<<"please input one character for cheek the password![ ]\b\b\b";
cin>>c;
switch(c)
{ case 's': stu();break; case 't':teach();break; default :cout<<"you are wrong !"; }
return 0;
}
解决 无用评论 打赏 举报
悬赏问题
- ¥20 删除和修改功能无法调用
- ¥15 kafka topic 所有分副本数修改
- ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
- ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?
- ¥40 串口调试助手打开串口后,keil5的代码就停止了
- ¥15 电脑最近经常蓝屏,求大家看看哪的问题
- ¥60 高价有偿求java辅导。工程量较大,价格你定,联系确定辅导后将采纳你的答案。希望能给出完整详细代码,并能解释回答我关于代码的疑问疑问,代码要求如下,联系我会发文档
- ¥50 C++五子棋AI程序编写
- ¥30 求安卓设备利用一个typeC接口,同时实现向pc一边投屏一边上传数据的解决方案。
- ¥15 SQL Server analysis services 服务安装失败