Exemple #1
0
int main()
{
    LinkList La;
    InitList_L(La);
    ElemType e;
    printf("Assigment for La:\n");
    CreateList_L(La,5);
    printf("The elements in La:\n");
    ListTraverse_L(La,Display_L);
    ListDelete_L(La, 2, e);
    printf("We have deleted the 2th element in La:\n");
    ListTraverse_L(La,Display_L);
    ListInsert_L(La, 2, e);
    printf("Put the element deleted in the proier statement in 2th:\n");
    ListTraverse_L(La,Display_L);
    LinkList Lb;
    InitList_L(Lb);
    printf("Assigment for another LinkList Lb:\n");
    CreateList_L(Lb,5);
    printf("The elements in Lb:\n");
    ListTraverse_L(Lb,Display_L);
    LinkList Lc;
    InitList_L(Lc);
    MergeList_L(La, Lb, Lc);
    printf("After merging La and Lb:\n");
    ListTraverse_L(Lc,Display_L);
    printf("The number of elements in Lb: %d\n",ListLength_L(Lc));
    Destroy_L(La);
    Destroy_L(Lb);
    Destroy_L(Lc);
    return 0;
}
Exemple #2
0
//对线性表的各个功能函数做测试
void ListTest()
{
	LinkList La,Lb,Lc;
	int i;
	ElemType temp;

	LinkList p;
	int j;

	CreatList_L( La, 5);
	printf("the list is:");
	for ( i=1; i<6; i++ )
	{
		GetElem_L( La, i, temp );
		printf("%d ",temp);
	}

	if ( ListInsert_L( La, 3,77) )
	{
		printf("\nthe insert list is:");
		for ( i=1; i<7; i++ )
		{
			GetElem_L( La, i, temp );
			printf("%d ",temp);
		}
	}
	
	if ( ListDelet_L( La, 3,temp) )
	{
		printf("\nthe delet list is:");
		for ( i=1; i<6; i++ )
		{
			GetElem_L( La, i, temp );
			printf("%d ",temp);
		}
	}

	
	CreatList_L( Lb, 5);
	printf("\n the list a is:");
	for ( i=1; i<6; i++ )
	{
		GetElem_L( La, i, temp );
		printf("%d ",temp);
	}
	printf("\n the list b is:");
	for ( i=1; i<6; i++ )
	{
		GetElem_L( Lb, i, temp );
		printf("%d ",temp);
	}
	MergeList_L( La, Lb, Lc);
	printf("\n the list c is:");
	for ( i=1; i<11; i++ )
	{
		GetElem_L( Lc, i, temp );
		printf("%d ",temp);
	}


}