con tro hay
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
class NGUOI
{
private:
char hoten[30];
int ngay,thang,nam;
public:
void nhap()
{
cout<<"
Ho va ten:";cin.ignore(1);cin.get(hoten,30);
cout<<"
Ngay sinh:";cin>>ngay;
cout<<"
Thang sinh:";cin>>thang;
cout<<"
Nam sinh:";cin>>nam;
}
void in()
{
cout<<"
Ho va ten:"<<hoten;
cout<<"
Ngay sinh:"<<ngay<<"/"<<thang<<"/"<<nam;
}
};
//class sinh vien
class SV:public NGUOI
{
private:
char lop[10];
float dtb;
public:
void nhap();
void in();
int kiemtra();
};
void SV::nhap()
{
NGUOI::nhap();
cout<<"
Lop:";cin>>lop;
cout<<"
Diem trung binh:";cin>>dtb;
}
void SV::in()
{
NGUOI::in();
cout<<"
Lop:"<<lop;
cout<<"
Diem trung binh:"<<dtb;
}
int SV::kiemtra()
{
if (dtb>8) return 1;
}
//class giao vien
class GV:public NGUOI
{
private:
char bomon[20];
int sobai;
public:
void nhap();
void in();
int kiemtra();
};
void GV::nhap()
{
NGUOI::nhap();
cout<<"
Bo mon:";cin>>bomon;
cout<<"
So bai bao:";cin>>sobai;
}
void GV::in()
{
NGUOI::in();
cout<<"
Bo mon:"<<bomon;
cout<<"
So bai bao:"<<sobai;
}
int GV::kiemtra()
{
if (sobai>=1) return 1;
}
//Ham main()
void main()
{
clrscr();
int i,n,c;
SV *a[10];GV *b[10];
do
{
cout<<"
";
cout<<"
Lua chon thao tac";
cout<<"
1.Thao tac tren lop sinh vien";
cout<<"
2.Thao tac tren lop giao vien";
cout<<"
3.Thoat";
cout<<"
--->Lua chon thao tac:";
c=getchar();
switch(c)
{
case '1':
clrscr();
cout<<"
Nhap so sinh vien:";cin>>n;
for (i=1;i<=n;++i)
{
cout<<"
Sinh vien thu "<<i<<":";
a[i]->nhap();
}
clrscr();
cout<<"
Danh sach sinh vien duoc khen thuong(Diem trung binh tren 8)";
for (i=1;i<=n;++i)
{
if (a[i]->kiemtra()==1) a[i]->in();
}
getchar();break;
case '2':
clrscr();
cout<<"
Nhap so giao vien:";cin>>n;
for (i=1;i<=n;++i)
{
cout<<"
Sinh vien thu "<<i<<":";
b[i]->nhap();
}
clrscr();
cout<<"
Danh sach giao vien duoc khen thuong(So bai bao it nhat la 1)";
for (i=1;i<=n;++i)
{
if (b[i]->kiemtra()==1) b[i]->in();
}
getchar();break;
}
}
while (c!='3');
getch();
}
Bạn đang đọc truyện trên: AzTruyen.Top