welcome tinhocK1 website

Saturday, 20/04/2024, 5:17 AM

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 danh sách theo thứ tự (bt cô châu photo ngày 03/11/208)
sắp xếp danh sách theo thứ tự
quocdat11 Date: Sunday, 09/11/2008, 1:58 PM | Message # 1
Nhóm: Removed





#include string.h
#include conio.h
#include stdio.h
#include iostream.h
class nguoi
{char*hoten;
char ten[12];

public:
nguoi() {hoten=new char[50];}
~nguoi() {delete[]hoten;}
void nhap();
void xuat();
int operator>(nguoi&s)
{if(strcmp(ten,s.ten)>0)
return 1;
else return 0;
}
nguoi&operator=(nguoi&s)
{strcpy(hoten,s.hoten);
strcpy(ten,s.ten);
}
};

void nguoi::nhap()
{cout<<"Ho ten:";
gets(hoten);
int i=strlen(hoten-1);
while(i>0&&hoten[i]==32)
hoten[i--]='\0';
while(i>0&&hoten[i]!=32)
i--;
strcpy(ten,hoten+i+1);
}
void nguoi::xuat()
{cout< void main()
{clrscr();
nguoi*ds;
int n;
cout<<"Nhap n=";
cin>>n;
ds=new nguoi[n];
for(int i=0;i {cout<<"Nguoi thu"< ds[i].nhap();
}
for(i=0;i for(int j=i+1;j if(ds[i]>ds[j])
{nguoi t;
t=ds[i];
ds[i]=ds[j];
ds[j]=t;
}
cout<<"Danh sach sau khi sap xep:"< for(i=0;i {cout< ds[i].xuat();
}
delete[]ds;
getch();
}

 
Forum » download » tài liệu chuyên ngành » sắp xếp danh sách theo thứ tự (bt cô châu photo ngày 03/11/208)
  • Page 1 of 1
  • 1
Search: