線性鍊錶的操作

2021-04-07 09:59:44 字數 1243 閱讀 4673

#include

#include

#include

#define error 0

#define ok 1

#define equal 1

#define overflow -1

#define list_init_size 100

#define listincrement 10

struct stustu[50];

typedef struct stu elemtype;

struct lnode

;typedef struct lnode lnode;

typedef struct lnode *linklist;

int init(linklist *l)

/*init */

int listlength(linklist l)

return j;

}int getelem(linklist l,int i,elemtype *e)

if(!p||j>1)  return error;

*e=p->data;

return ok;

}int equallist(elemtype *e1,elemtype *e2)

int less_equallist(elemtype *e1,elemtype *e2)

int locateelem(linklist la,elemtype e,int type)

return 0;

break;

default:

break;

}return 0;

}void mergelist(linklist la,linklist lb,linklist *lc)

else

}pc->next=pa?pa:pb;

free(lb);

}int printlist(linklist l)

printf("/n");

}int listinsert(linklist l,int i,elemtype e)

if(!p||j>i-1) return error;

s=(linklist)malloc(sizeof(lnode));

s->data=e;

s->next=p->next;

p->next=s;

return ok;

}/*listinsert before i */

main()

線性鍊錶的實現和操作

本次實現的是線性鍊錶的操作,和上次單鏈表不同在於,上次只實現了表頭的插入和刪除,這次是對線性表的整體實現插入和刪除 廢話不多說,直接看 linked llist.h includeusing namespace std template struct node template class link...

對線性鍊錶的完整操作(1)

include include define maxsize 50 typedef int elemtype typedef struct lnode linklist 單鏈表結點型別 建立鍊錶 頭插法建表 得到逆序結果 void createlistf linklist l,elemtype a,...

線性鍊錶基本操作實現(C C )

函式結果狀態 define true 1 define false 0 define ok 1 define error 0 define infeasible 1 define null 0 define overflow 2 include include include using names...