Home > Back-end >  Turn to for help, urgent urgent, how to write, a great god help for this program added content
Turn to for help, urgent urgent, how to write, a great god help for this program added content

Time:10-30

The realization of the four order stack
A, the experiment purpose
1. To master the order of the stack storage structure
2. Realize the basic operation of the stack

Second, the experiment content
1. Stack initialization sequence;
2. Into the stack;
3. Out of the stack;
4. Take the stack elements;
5. Whether the stack is empty;
6. Whether the stack is full,
Three, program implementation
Complete the following code, and computer implementation, will be after the results is attached file:
#include
#include
# define MaxSize 100
Typedef int dataType.
Typedef struct {
DataType data [MaxSize];
int top;
} SeqStack;

//create order stack
SeqStack * createStack ()
{
SeqStack * t=(SeqStack *) malloc (sizeof (SeqStack));
T - & gt; Top=1;
Return t;
}

//whether the stack is empty

//whether the stack with

//element x into the stack

//the stack

//take value of the stack element

The number of elements in the stack//o


Int main ()
{
SeqStack * s=createStack ();//create order stack
Push (s, 80);
Push (s, 90);
Pop (s);
Push (s, 70);
Printf (" % d elements, stack top element is: % d \ n ", the size (s), the top (s));
}