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;
}
解决 无用评论 打赏 举报
悬赏问题
- ¥15 如何在scanpy上做差异基因和通路富集?
- ¥20 关于#硬件工程#的问题,请各位专家解答!
- ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
- ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
- ¥30 截图中的mathematics程序转换成matlab
- ¥15 动力学代码报错,维度不匹配
- ¥15 Power query添加列问题
- ¥50 Kubernetes&Fission&Eleasticsearch
- ¥15 報錯:Person is not mapped,如何解決?
- ¥15 c++头文件不能识别CDialog