//列出列表的所有元素 void DisplayAllElements(LinkList list) { int flag=1; LinkList point = list->next; while(point) { printf("%d\t",point->data); point = point->next; if(flag++==5) printf("\n"); } printf("\n"); }
主函数:
#include "head.h"
void main() { LinkList listA,listB;
printf("Create LinkList A\n"); listA = CreateListOrdinal_L(4); ListInsert_L(listA,4,123); ListDelete_L(listA,3); BubbleSort(listA); printf("After sort,the elements of listA are:\n"); DisplayAllElements(listA);
printf("Create LinkList B\n"); listB = CreateList_L(6); BubbleSort(listB); printf("After sort,the elements of listB are:\n"); DisplayAllElements(listB);
MergeList_L(listA,listB); printf("\nAfter merge the two list together,the elements are:\n"); DisplayAllElements(listA);
printf("\nThe length of elements of listA is:%d",GetListLength_L(listA));