第十一天

来源:互联网 发布:武汉纬创纬尊软件 编辑:程序博客网 时间:2024/05/01 11:07

链表模版:




宿主结构(带数据的结构体)

typedef struct  student{

int age;

struct list_head list;

}student;


struct list_head{

struct list_head* prev;

struct list_head* next;

}

创建宿主结构

student *std1=(student *)malloc(sizeof(student));

std1->age=10;

init_list(&(std1->list));



链栈:头插法,头删法

特点:先进后出。

压栈就是入栈。

struct  Stack{   int data;   struct Stack *next;}

创建栈:

Stack *create(int data);

压栈

bool  push_stack(Stack *p,int data);

出栈:

bool pop_stack(Stack *p,int data);


0 0