스 택(Stack)

■ 스택의 배열 구현 ---> 스택의 PUSH 와 POP

[ push 함수 ]

void push(int x, STACK S)
{
     if(is_full(S)) error("Full stack");
     else S->array[++S->top]=x;
}

 

[ pop과 출력 함수 ]

int pop(STACK S)
{
     if(is_empty(S)) error("Empty stack");
     else return S->array[S->top--];
}