#include<conio.h>
#include<stdio.h>
#include<string.h>
class cmt
{
private:
char *so;
char *ten;
int nam;
public:
cmt();
~cmt();
cmt & operator = (cmt &);
friend ostream & operator << (ostream & os, cmt &); friend istream & operator >> (istream & is, cmt &); int namsinh();
};
cmt::cmt()
{
so= new char[11];
nam=0;
ten= new char[25];
};
cmt::~cmt()
{
delete so;
nam=0;
Trang 2delete ten;
};
cmt&cmt:: operator = ( cmt &a)
{
so = new char [11];
ten = new char [25];
strcpy(so,a.so);
nam=a.nam;
strcpy(ten,a.ten);
return a;
};
ostream & operator << (ostream & os, cmt &a) {
cout<<"\n ten : "<<a.ten<<endl;
cout<<"\n so cmt : "<<a.so<<endl; cout<<"\n nam sinh la : "<<a.nam; return os;
};
istream & operator >> (istream & is, cmt &a) {
cout<<"\n nhap ten ";
cin>>a.ten;
cout<<"\n nhap so cmt ";
cin>>a.so;
cout<<"\n nhap nam sinh ";
cin>>a.nam;
return is;
};
Trang 3int cmt::namsinh()
{
return nam;
};
void nhap1(cmt a[],int k)
{
for(int i=0;i<k;i++)
{
cout<<"\n nhap cmt thu "<<i+1; cin>>a[i];
};
};
cmt max(cmt a[],int k)
{
cmt temp;
temp=a[0];
for(int i=1;i<k;i++)
if(temp.namsinh()>a[i].namsinh()) temp=a[i];
return temp;
};
float tb(cmt a[],int k)
{
float t=0;
for(int i=0;i<k;i++)
t=t+(2013-a[i].namsinh());
t=t/k;
return t;
Trang 4int main()
{
cmt a[60];
int n;
cout<<"\n nhap so cac so chung minh thu "; cin>>n;
cout<<"\n nhap gia tri cac the chung minh thu "; nhap1(a,n);
cout<s<"\n tuoi lon nhat "<<max(a,n);
cout<<"\n gia tri trung binh "<<tb(a,n);
};