#include<stdio.h>
#define MAXSIZE 5
// First In, Last Out
int stack[MAXSIZE] = {0}, top = 0;
void input(int k) {
if(top==MAXSIZE) {
printf("Stack is FULL\n");
return ;
}
stack[top] = k;
top++;
}
void output() {
if(top==0) {
printf("STack is Empty\n");
return ;
}
top=--;
printf("output data is %d\n", stack[top]);
stack[top] = 0;
}
void show() {
for(int i=MAXSIZE-1; i>=0; i--) {
printf("%d: %d\n", i, stack[i]);
}
}
int main() {
int n, k;
for(;;) {
printf("1: input, 2:output, 3:view, 4~: error\n");
scanf("%d", &n);
switch(n) {
case 1:
printf("input value: ");
scanf("%d", &k);
input(k);
break;
case 2:
output();
break;
case 3:
show();
break;
default:
printf("input error\n");
}
}
}