Advertisement

线性表就地逆置

阅读量:
复制代码
 #include<stdio.h>

    
 #include<malloc.h>
    
 #include<stdlib.h>
    
 #include<LinkList.h>
    
  
    
 void main()
    
 {
    
 	int a[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    
 	int i;
    
 	LinkList L;
    
 	InitList(&L);
    
 	for (i = 1; i <= sizeof(a) / sizeof(a[0]); i++)
    
 	{
    
 		if (InsertList(L, i, a[i - 1]) == 0)
    
 		{
    
 			printf("位置不合法!");
    
 			return;
    
 		}
    
 	}
    
 	DisplayList(L);
    
 	ReverseList(L);
    
 	DisplayList(L);
    
 }
    
    
    
    
复制代码
 /*LinkList.h*/

    
 #include "stdio.h"
    
 #include "math.h"

全部评论 (0)

还没有任何评论哟~