#include<stdio.h>
#include<stdlib.h>

#ifndef _Stack_h

struct Node;
typedef struct Node *PtyToNode;
typedef PtrToNode Stack;

int IsEmpty(Stack S);
Stack CreatStack(void);
void MakeEmpty(Stack S);
void Push(Element x, Stack s);
ElementType Top(Stack s);
void Pop(Stack s);

#endif
struct Node


{
ElementType Element;
PtrToNode Next;
};
int
IsEmpty(Stack s)

{
return s->Next==NULL;
}
Stack
CreatStack(void)

{
Stack s;
s=(struct *)malloc(sizeof(struct Node));
if(s==NULL)

{ printf("Out of Space !"); exit(1);}
s->Next=NULL;
MakeEmpty(s);
return s;
}
void
MakeEmpty(Stack s)

{
if(s==NULL)

{printf("Must use CreatStack first !"); exit(1);}
while(!IsEmpty(s))
pop(s);
}
void
Push(Element x,Stack s)

{
PtrToNode tmpcell=(Stack s)malloc(sizeof(Node));
if(tmpcell==NULL)

{printf("Out of space !"); exit(1);}
tmpCall->Element=x;
tmpCell->Next=s->Next;
s->Next=tmpcell;
}
ElementType
Top(Stack s)

{
if(IsEmpty(Stack s))

{printf("Empty stack !"); exit(1);}
return s->Next->Element;
}
void
Pop(Stack s)

{
if(IsEmpty(Stack s))

{printf("The stack is empty !"); exit(1);}
Stack firstCell=s->Next;
s->Next=s->Next->Next;
free(firstCell);
}
