//Made By Korbear
//http://korbear.tistory.com/
#include <stdio.h>
#include <stdlib.h>
#define S_SIZE 5 //stack size
int stack[S_SIZE];
int top = -1;
void push(){
int value;
printf("값 입력 : ");
scanf("%d", &value);
if (top >= S_SIZE-1)
printf("\n Stack Full \n");
else
stack[++top] = value;
}
void pop(){
if (top<0)
printf("\n Stack Empty \n");
else
stack[top--];
}
void show(){
int i = 0;
printf("\n STACK [ ");
for (i = 0; i <= top; i++){
printf("%d ", stack[i]);
}
printf("] ");
}
int main(int argc, char *argv[]) {
int a=0, b=1;
while (b){
printf("\n1 : Push\n2 : pop\n3 : Show\n4 : out\n\n", a);
scanf("%d", &a);
switch (a){
case 1:
push();
break;
case 2:
pop();
break;
case 3:
show();
break;
case 4:
b = 0;
break;
}
}
return 0;
}