cslt c3_de thi
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
class NGUOI
{ protected:
char ht[30];
char ns[10];
public:
void nhap();
void xuat();
};
void NGUOI::nhap()
{ cout<<"
nhap ho va ten:"; gets(ht);
cout<<"
nhap ngay thang nam sinh:" ;gets(ns);
}
void NGUOI::xuat()
{ cout<<"
ho va ten:"<<ht;
cout<<"
ngay sinh:"<<ns;
}
class SV:public NGUOI
{ private:
char lop[15];
float dtb;
public:
void nhap();
void xuat();
int kt();
};
void SV::nhap()
{ NGUOI::nhap();
cout<<"
nhap lop cua sinh vien:"; gets(lop);
cout<<"
nhap diem trung binh:"; cin>>dtb;
}
void SV::xuat()
{ NGUOI::xuat();
cout<<"
lop:"<<lop;
cout<<"
diem trung binh:"<<dtb;
}
int SV::kt()
{ if((dtb>=8)&&(dtb<=10)) return 1;
else return 0;
}
class GV:public NGUOI
{ char bm[20];
int sb;
public:
void nhap();
void xuat();
int kt();
} ;
void GV::nhap()
{ NGUOI::nhap();
cout<<"
nhap bo mon giang day:";gets(bm);
cout<<"
nhap so bai viet:";cin>>sb;
}
void GV::xuat()
{ NGUOI::xuat();
cout<<"
bo mon:"<<bm;
cout<<"
so bai viet"<<sb;
}
int GV::kt()
{ if(sb>=1) return 1;
else return 0;
}
void main()
{ clrscr();
fflush(stdin);
int ch,k;
do
{cout<<"
1 la thao tac tren lop NGUOI:";
cout<<"
2 la thao tac tren lop SV:";
cout<<"
3 la thao tac tren lop GV:";
cout<<"
ban chon:";
cin>>k;
switch(k)
{
case 1:
int n,i,z; NGUOI a[150];
cout<<"
nhap so nguoi:";cin>>n;
for (i=1; i<=n; i++)
{cout<<"
nhap nguoi thu "<<i<<":";a[i].nhap();}
cout<<"
can in nguoi thu bn?"; cin>>z;
for(i=1;i<=n;i++) if(i==z) a[i].xuat();
break;
case 2: int m,j;
SV b[100];
cout<<"
nhap so sinh vien:"; cin>>m;
for (j=1;j<=m;j++)
{cout<<"
nhap dinh vien thu"<<j<<":";b[j].nhap(); }
cout<<"
danh sach dv dc khen thuong:";
for (j=1;j<=m; j++) if(b[j].kt()==1) b[j].xuat();
if(b[j].kt()==0)
cout<<"
ko co sinh vien nao dc thuong!";
break;
case 3: int p,t;
GV c[30];
cout<<"
nhap so giao vien:";cin>>p;
for ( t=1; t<=p; t++)
{
cout<<"
nhap gian vien thu"<<t<<":";c[t].nhap();}
cout<<"
danh sach giao vien dc khen thuong:";
for (t=1; t<=p; t++) if(c[t].kt()==1) c[t].xuat();
if(c[t].kt()==0)
cout<<"
ko co giao vien nao dc thuong";
break;
default: cout<<"
nhap sai:";
}
cout<<"
ban co thuc hien tiep ko?
1 la co:
2 la ko:";
cin>>ch;
}
while(ch==1);
getch();
}
Bạn đang đọc truyện trên: AzTruyen.Top