Linked list operation

Source: Internet
Author: User

# Include "iostream. h"
# Include "iomanip. h"

Typedef int ElemType;

Typedef struct ADTList
{
ElemType Elem;
Struct ADTList * next;
} ADTList;
////////////////////////////////////////
// Linked list function
Bool InitList (ADTList * & L );
Void DestroyList (ADTList * L );
Void ClearList (ADTList * L );
Bool ListEmpty (ADTList * L );
Long ListLength (ADTList * L );
Bool GetElem (ADTList * L, long index, ElemType & e );
Long LocateElem (ADTList * L, ElemType e );
Int compare (ElemType elem1, ElemType elem2 );
Bool PriorElem (ADTList * L, ElemType cur_e, ElemType & pre_e );
Bool NextElem (ADTList * L, ElemType cur_e, ElemType & next_e );
Bool ListInsert (ADTList * L, long index, ElemType e );
Bool ListDelete (ADTList * L, long index, ElemType & e );
Bool visit (ElemType elem );
Bool ListTraverse (ADTList * L );
///////////////////////////////////////
// Test functions
Bool create (ADTList * L );
Bool create1 (ADTList * L );
Bool deleteTest (ADTList * L );
///////////////////////////////////////
Int main (int argc, char ** argv)
{
ADTList * list;
List = NULL;

Cout <"linked list experiment program" <///////////////////////////////////////
Cout <"List Init:" <If (! InitList (list ))
Return 1;
///////////////////////////////////////
If (! Create (list ))
Return 1;
Cout < if(!ListTraverse(list))
  return 1;
///////////////////////////////////////
 cout<ClearList (list );
Cout < if(!ListTraverse(list))
  return 1;
///////////////////////////////////////
 if(!create1(list))
  return 1;
 cout<If (! ListTraverse (list ))
Return 1;
///////////////////////////////////////
DeleteTest (list );
///////////////////////////////////////

Return 0;
}

<

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.