#include <iostream>
using namespace std;
typedef struct StackNode {
int data;
struct StackNode* next;
}StackNode, * LinkStack;
int InitStack(LinkStack& S) {
S = NULL;
return 1;
}
int Push(LinkStack& S, int e) {
LinkStack p;
p = new StackNode;
p->data = e;
p->next = S;
S = p;
return 1;
}
int Pop(LinkStack& S, int e) {
LinkStack p;
e = S->data;
p = S;
S = S->next;
delete p;
return 1;
}
int GetTop(LinkStack& S) {
return S->data;
}
int main()
{
LinkStack stack;
InitStack(stack);
Push(stack, 10);
cout << GetTop(stack) << endl;
Push(stack, 20);
cout << GetTop(stack) << endl;
Push(stack, 30);
cout << GetTop(stack) << endl;
}
标签:LinkStack,return,int,next,链栈,StackNode,data
From: https://www.cnblogs.com/qianyuzz/p/17059927.html