Bai1
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class hocsinh
{
char hoten[25];
int lop;
float dtoan,dly,dhoa,tb;
public:
void nhap()
{
cout<<"Ho ten:";
fflush(stdin);
gets(hoten);
cout<<"lop:";cin>>lop;
cout<<"diemtoan:";cin>>dtoan;
cout<<"diem ly:";cin>>dly;
cout<<"diem hoa:";cin>>dhoa;
tb=(dtoan+dly+dhoa)/3;
}
void xuat()
{
cout<<"
hoten:"<<hoten;
cout<<"
lop:"<<lop;
cout<<"
diem toan:"<<dtoan;
cout<<"
diem ly:"<<dly;
cout<<"
diem hoa:"<<dhoa;
cout<<"
diemtrungbinh:"<<tb;
}
void sapxep()
{
if(tb>=5)
{
cout<<"
"<<hoten;
cout<<" "<<lop;
cout<<" "<<dtoan;
cout<<" "<<dly;
cout<<" "<<dhoa;
cout<<" "<<tb;
}
}
};
hocsinh sinhvien[100];
main()
{
int i,n;
cout<<"nhap so sinh vien: ";cin>>n;
for(i=0;i<n;i++)
{
sinhvien[i].nhap();
}
for(i=0;i<n;i++)
{
sinhvien[i].xuat();
cout<<"
";
}
cout<<"
nhung sinh vien co diem trung binh >=5";