【www.gdgbn.com--C语言】

#include "iostream.h"
#include "iomanip.h"

typedef int ElemType;

typedef struct ADTList
{
 ElemType Elem;
 struct ADTList *next;
}ADTList;
////////////////////////////////////////
//链表功能函数
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);
///////////////////////////////////////
//测试用函数
bool create(ADTList *L);
bool create1(ADTList *L);
bool deleteTest(ADTList *L);
///////////////////////////////////////
int main(int argc,char **argv)
{
 ADTList *list;
 list=NULL;

 cout<<"链表实验程序"<///////////////////////////////////////
 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;  
}

本文来源:http://www.gdgbn.com/asp/13153/