1.代码编译错误是为啥啊
2.可以的话能把这个栈帧的链式存储结构在此代码的基础上修改一下么
#include <stdio.h>
#include <stdlib.h>
typedef int ElementType
struct Stack {
ElementType Data;
struct Stack *Next;
};
struct Stack CreateStack() { //头结点
struct Stack *S;
S = (struct Stack *)malloc(sizeof(struct Stack));
S -> Next = NULL;
return S;
}
void Push(ElementType item, struct Stack *S) {
struct Stack *TmpCell;
TmpCell = (struct Stack *)malloc(sizeof (struct Stack));
TmpCell -> Element = item;
TmpCell -> Next = S -> Next;
S -> Next = TmpCell;
}
//链表不需要判别是否满了
ElementType Pop(struct Stack *S) {
//删除并返回堆栈S的栈顶元素
struct Stack *FirstCell;
ElementType TopElem;
if (IsEmpty(S)) {
printf("堆栈空");
return 0;
} else {
FirstCell = S-> Next;
S->Next = FirstCell -> Element;
free(FirstCell);
return TopElem;
}
}
int main() {
return 0;
}