welcome tinhocK1 website

Thursday, 18/04/2024, 4:51 PM

Chào Guest

Login form

Đăng nhập:
mật khẩu:

Ẩn

Tán Gẫu

500

Bạn thấy web tinhoc K1 thế nào?

Rate my site
Total of answers: 108
[ New messages · Members · Forum rules · Search · RSS ]
  • Page 1 of 1
  • 1
Forum » download » tài liệu chuyên ngành » sắp xếp tuổi (bt sáng 10/11/08)
sắp xếp tuổi
quocdat11 Date: Monday, 10/11/2008, 3:14 PM | Message # 1
Nhóm: Removed





#include iostream.h
#include conio.h
#include stdio.h
#include string.h
#include iomanip.h
class person
{char *hoten;
unsigned int tuoi;

public:
person();
person(char*,unsigned int);
person(const person&);
~person() {delete[]hoten;}
void nhap();
void xuat();
person&operator=(const person&);
friend void sapxep(person*,int);
};
void sapxep(person*ds,int n)
{for(int i=0;i for(int j=i+1;j if(ds[i].tuoi>ds[j].tuoi)
{person t;
t=ds[i];
ds[i]=ds[j];
ds[j]=t;
}
}
person::person()
{hoten=new char[60];
tuoi=0;
}
person::person(char*ht,unsigned int t)
{hoten=strdup(ht);
tuoi=t;
}
person::person(const person&t)
{if(hoten!=NULL)
delete[]hoten;
hoten=strdup(t.hoten);
tuoi=t.tuoi;
}
person&person::operator=(const person&t)
{hoten=new char[50];
strcpy(hoten,t.hoten);
tuoi=t.tuoi;
return*this;
}
void person::nhap()
{cout<<"Ho ten:";
gets(hoten);
cout<<"Tuoi:";
cin>>tuoi;
}
void person::xuat()
{cout< cout< }
void main()
{clrscr();
person*ds;
int n;
cout<<"Nhap so nguoi:";
cin>>n;
for(int i=0;i {cout<<"Thong tin nguoi thu:"< ds[i].nhap();
}
clrscr();
sapxep(ds,n);
cout<<"\nDanh sach sau khi sap xep:"< cout< for(i=0;i ds[i].xuat();
delete[]ds;
getch();
}

chúc các bạn học tốt

 
Forum » download » tài liệu chuyên ngành » sắp xếp tuổi (bt sáng 10/11/08)
  • Page 1 of 1
  • 1
Search: