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;
}
解决 无用评论 打赏 举报
悬赏问题
- ¥35 平滑拟合曲线该如何生成
- ¥100 c语言,请帮蒟蒻写一个题的范例作参考
- ¥15 名为“Product”的列已属于此 DataTable
- ¥15 安卓adb backup备份应用数据失败
- ¥15 eclipse运行项目时遇到的问题
- ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
- ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
- ¥15 自己瞎改改,结果现在又运行不了了
- ¥15 链式存储应该如何解决
- ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站