[Library] Danh sách (ALISTLIB)

//Sap xep day tang dan
void swap(Position a, Position b, List *L){
     ElementType temp;
void Sort_List(List *L){
     Position P=FirstList(*L);
     while (P!=EndList(*L)){
           Position Q=Next(P,*L);
           while (Q!=EndList(*L)){
                 if (Retrieve(P,*L)>Retrieve(Q,*L))
//Tim so lon nhat – So nho nhat
ElementType SLN(List L) {
     Position P=FirstList(L);
     ElementType Max=Retrieve(P,L);
     while (P!=EndList(L)){
           if (Retrieve(P,L)>Max)
           else P=Next(P,L);
           return Max;
ElementType SNN(List L) {
     Position P=FirstList(L);
     ElementType Min=Retrieve(P,L);
     while (P!=EndList(L)){
           if (Retrieve(P,L)<Min)
           else P=Next(P,L);
           return Min;
//Them phan tu vao danh sach co thu tu
Position OrderLocate(ElementType X, List L){
         Position P;
         int found = 0;
         P = FirstList(L);
         while ((P!=EndList(L)) && (Retrieve(P,L)<X) && (found==0)){
               if (Retrieve(P,L)==X) {
               else P = Next(P,L);
               return P;
void Insert_OrderList(ElementType X, List *L){
     Position P = OrderLocate(X,*L);
//Dem phan tu X trong danh sach co thu tu 
int Quantity_X_Order(ElementType X, List L){
    int cnt=0;
    ElementType temp;
    Position P=OrderLocate(X,L);
    if (P!=EndList(L)){
       while (Retrieve(P,L)==X){
    return cnt;

Kita welcomes your comments...

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s