#include<stdio.h>
#include<stdlib.h>
#pragma warning(disable:4996)
#define elemType int
#define maxSize 50
typedef struct seqStack {
elemType arr[maxSize];
int top;
}seqStack;
void initStack(seqStack* stack) {
for (int i = 0;i < maxSize;i++) {
stack->arr[i] = 0;
}
stack->top = -1;
}
bool pushStack(seqStack* stack, elemType data) {
if (stack->top+1 == maxSize) {
return false;
}
stack->arr[++stack->top] = data;
return true;
}
bool popStack(seqStack* stack, elemType* dataReturn) {
if (stack->top == -1) {
return false;
}
*dataReturn = stack->arr[stack->top--];
return true;
}
bool getTopStack(seqStack* stack, elemType* dataReturn) {
if (stack->top == -1) {
return false;
}
*dataReturn = stack->arr[stack->top];
return true;
}
int main() {
seqStack s;
initStack(&s);
for (int i = 0;i < 50;i += 2) {
pushStack(&s, i);
}
elemType data;
while (popStack(&s, &data)) {
printf("%d\n", data);
}
return 0;
}