数据结构1.3.2链栈的实现

#include
#include
#include
#include

typedef struct book{
	char isbn[20];
	char name[10];
	double price;
}Book;

typedef struct Linkstack{
	Book date;
	struct Linkstack *next;
}Linkstack; 

int main(void)
{
	return 0;
}

bool init_stack(Linkstack **S)
{
	S=NULL;
	return true;
}

bool press_stack(Linkstack **S, Book e)
{
	Linkstack *p;
	p = (Linkstack*)malloc(sizeof(Linkstack));
	p->date = e;
	p->next = *S;
	(*S) = p;
	return true;
}

bool deliver_stack(Linkstack **S, Book *e)
{
	if(S == NULL)
	{
		return false;
	}
	*e = (*S)->date;
	Linkstack *p;
	p = (*S);
	(*S) = (*S)->next;
	free(p);
	return true;
}

Book get_top(Linkstack *S)
{
	if(S != NULL)
	{
		return S->date;
	}
}

你可能感兴趣的:(编程学习笔记,学习)