#include<stdio.h>
#include<string.h>
#include<string>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
#define OK 1
#define ERROR 0
typedef int status;
typedef int Elemtype;
typedef struct stackNode
{
Elemtype data;
struct stackNode *next;
} stackNode,*linkNode;
typedef struct linkStack
{
linkNode top;
int stacksize;
} linkStack;
status push(linkStack &s,Elemtype e)
{
linkNode p,q;
p=(stackNode *)malloc(sizeof(stackNode));
if(p==NULL)return ERROR;
p->data=e;
p->next=s->top;
s->top=p;
s->stacksize++;
return OK;
}
status pop(linkStack &s)
{
linkStack p;
p=s->top;
s->top=p->top;
free(p);
s.stacksize--;
return OK;
}
status traverse(linkStack s){
while(s->top!=NULL){
printf("%d ",s.top->data);
s.top=s->top;
}
return OK;
}
#include<string.h>
#include<string>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
#define OK 1
#define ERROR 0
typedef int status;
typedef int Elemtype;
typedef struct stackNode
{
Elemtype data;
struct stackNode *next;
} stackNode,*linkNode;
typedef struct linkStack
{
linkNode top;
int stacksize;
} linkStack;
status push(linkStack &s,Elemtype e)
{
linkNode p,q;
p=(stackNode *)malloc(sizeof(stackNode));
if(p==NULL)return ERROR;
p->data=e;
p->next=s->top;
s->top=p;
s->stacksize++;
return OK;
}
status pop(linkStack &s)
{
linkStack p;
p=s->top;
s->top=p->top;
free(p);
s.stacksize--;
return OK;
}
status traverse(linkStack s){
while(s->top!=NULL){
printf("%d ",s.top->data);
s.top=s->top;
}
return OK;
}