# Include <stdio. h>
# Include <stdlib. h>
# Define stacksize 100
Typedef int datatype;
Typedef struct
{
Datatype data [stacksize];
Int top;
} Seqstack;
Typedef struct node {
Datatype data;
Struct node * next;
} Listnode;
Typedef listnode * linklist;
Linklist head;
Linklist p;
Int count;
Linklist creatlist (int n)
{
Linklist head;
Listnode * p1, * p2;
Int I;
Head = (linklist) malloc (sizeof (listnode ));
Head-> next = NULL;
P2 = head;
Printf ("Please input the records of the chain! N ");
For (I = 0; I <n; I ++)
{
P1 = (linklist) malloc (sizeof (listnode ));
Scanf ("% d", & p1-> data );
P1-> next = p2-> next;
P2-> next = p1;
P2 = p1;
}
Return (head );
}
Void print (linklist head, int n)
{
If (head = NULL)
Printf ("list null! N ");
Printf ("Now these % d records are: n", n );
P = head-> next;
Printf ("% 4d", p-> data );
Count = 1;
While (p-> next! = NULL)
{
Count ++;
P = p-> next;
Printf ("% 4d", p-> data );
If (! (Count % 10 ))
Printf ("n ");
}
}
Datatype push (seqstack * s, int x)
{
If (s-> top = stacksize-1)
Printf ("The stack is overflow! N ");
Else
S-> data [++ s-> top] = x;
}
Datatype pop (seqstack * s)
{
If (s-> top =-1)
Printf ("the stack is empty! N ");
Else
Return (s-> data [s-> top --]);
}