#include "stdio.h"
#include "stdlib.h"
#define N sizeof(struct stack)
typedef struct stack{
int data;
struct stack *next;
}*pstack;
//置空链栈
pstack empty(pstack top){
top = NULL;
printf("栈已经置空!\n");
return top;
}
//判断栈空
void isempty(pstack top){
if (top == NULL)
printf("链栈为空!\n");
else
printf("链栈不为空!\n");
}
//入链栈
pstack push(pstack top){
pstack p;
int k;
#include "stdlib.h"
#define N sizeof(struct stack)
typedef struct stack{
int data;
struct stack *next;
}*pstack;
//置空链栈
pstack empty(pstack top){
top = NULL;
printf("栈已经置空!\n");
return top;
}
//判断栈空
void isempty(pstack top){
if (top == NULL)
printf("链栈为空!\n");
else
printf("链栈不为空!\n");
}
//入链栈
pstack push(pstack top){
pstack p;
int k;

本文展示了如何使用C语言创建一个链栈,并实现置空、判断栈空、入栈、出栈和获取栈顶元素的功能。通过主函数中提供的菜单选项,用户可以交互式地进行各种链栈操作。
最低0.47元/天 解锁文章
2万+

被折叠的 条评论
为什么被折叠?



