You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
458 B
36 lines
458 B
4 years ago
|
#include <stdbool.h>
|
||
|
|
||
|
#define STACK_SIZE 100
|
||
|
|
||
|
//void stack_overflow(void);
|
||
|
|
||
|
/* external variables */
|
||
|
int contents[STACK_SIZE];
|
||
|
int top = 0;
|
||
|
|
||
|
void make_empty(void) {
|
||
|
top = 0;
|
||
|
}
|
||
|
|
||
|
bool is_empty(void) {
|
||
|
return top == 0;
|
||
|
}
|
||
|
|
||
|
bool is_full(void) {
|
||
|
return top == STACK_SIZE;
|
||
|
}
|
||
|
|
||
|
void push(int i) {
|
||
|
// if (is_full())
|
||
|
// stack_overflow();
|
||
|
// else
|
||
|
contents[top++] = i;
|
||
|
}
|
||
|
|
||
|
int pop(void) {
|
||
|
// if (is_empty())
|
||
|
// stack_overflow();
|
||
|
// else
|
||
|
return contents[--top];
|
||
|
}
|