设计一个大中学生和教师管理程序

 #include <iostream.h>
class person
{
protected:
int no;
char name[8];
public:
 void getdata()
 {
  cout << " 编号:";
  cin >> no;
  cout << " 姓名:";
  cin >> name;
 }
 void dispdata()
 {
  cout << " 编号:" << no << endl;
  cout << " 姓名:" << name << endl;
 }
};
class teacher : public person
{
protected:
 char prof[10];
 char depart[10];
public:
 void getdata()
 {
  cout << "输入一个教师数据:" << endl;
  person::getdata();
  cout << "  职称:";
  cin >> prof;
  cout << "  教研室:";
  cin >> depart;
 }
 void dispdata()
 {
  cout << "输出一个教师数据:" << endl;
  person::dispdata();
  cout << " 职称:" << prof << endl;
  cout << " 教研室:" << depart << endl;
 }
};
class student : public person
{
protected:
 char sex[2];
 char cname[10];
public:
 void getdata()
 {
  person::getdata();
  cout << "性别:";
  cin >> sex;
  cout << "  班号:";
  cin >> cname;
 }
 void dispdata()
 {
  person::dispdata();
  cout << "性别:" << sex << endl;
  cout << "  班号:" << cname << endl;
 }
};
class unstudent:public student
{
private:
 int degree1;
 int degree2;
 int degree3;
public:
 void getdata()
 {
  cout << "输入一个大学生数据:" << endl;
  student::getdata();
  cout << " 英语:";
  cin >> degree1;
  cout << " 高等数学:";
  cin >> degree2;
  cout << " 数据结构:";
  cin >> degree3;
 }
 void dispdata()
 {
  cout << "输出一个大学生数据:" << endl;
  student::dispdata();
  cout << " 英语:" << degree1 << endl;
  cout << " 高等数学:" << degree2 << endl;
  cout << " 数据结构:" << degree3 << endl;
  cout << " 平均分:" << (degree1+degree2+degree2)/3 << endl;
 }
};
class mistudent:public student
{
private:
 int degree1;
 int degree2;
 int degree3;
public:
 void getdata()
 {
  cout << "输入一个中学生数据:" << endl;
  student::getdata();
  cout << " 英语:";
  cin >> degree1;
  cout << " 数学:";
  cin >> degree2;
  cout << " 语文:";
  cin >> degree3;
 }
 void dispdata()
 {
  cout << "输出一个中学生数据:" << endl;
  student::dispdata();
  cout << " 英语:" << degree1 << endl;
  cout << " 数学:" << degree2 << endl;
  cout << " 语文:" << degree3 << endl;
  cout << " 平均分:" << (degree1+degree2+degree2)/3 << endl;
 }
};
void main()
{
 teacher t;
 t.getdata();
 unstudent s1;
 s1.getdata();
 mistudent s2;
 s2.getdata();
 t.dispdata();
 s1.dispdata();
 s2.dispdata();
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值