https://www.acmicpc.net/short/status/10828/0/2
https://www.google.com/amp/s/www.geeksforgeeks.org/stack-data-structure-introduction-program/amp/
#include <stdio.h>
int A[10000];
int main()
{
int n,*p=A;
char s[6];
for(scanf("%d",&n);n--;)
{
scanf("%s",s);
if(s[1]=='u') scanf("%d",p++);
if(s[0]=='t') printf("%d\n",p==A ? -1 : *(p-1));
if(s[0]=='s') printf("%d\n",p-A);
if(s[0]=='e') printf("%d\n",p==A);
if(s[0]=='p' && s[1]=='o') printf("%d\n",p==A ? -1 : *--p);
}
return 0;
}
??? : 그거 그렇게 하는거 아닌데 ㅋㅋ
포인터랑 배열 하나씩만 있으면 충분.
push 4 처럼 두개의 인자를 받는 경우,
scanf는 스페이스바 또는 개행 문자가 들어오면 읽는 것을 중단함. 근데 이렇게 쓰면 stdin 버퍼에 문자가 들어간 상태라 바로 읽어들임.
scanf("%s", cmd);
scanf("%d", &a);
// push 4 -> allocates "push" to cmd, 4 to a.