/*
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a,k[100001]={0},i,e,b=1,h=0;
scanf("%d",&a);
for(i=1;i<=a;i++)
{
scanf("%d",&e);
if(e==0)
{
b--;
k[b]=0;
}
else
{
k[b]=e;
b++;
}
}
for(i=1;i<=a;i++)
{
h=h+k[i];
}
printf("%d",h);
}
*/
/*
#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");
}
}
}
*/
#include<stdio.h>
#define MAXSIZE 5
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()
{
top--;
printf("output data is %d\n",stack[top]);
stack[top]=0;
}
void show()
{
for(int i=MAXSIZE;i>=0;i--)
{
printf("%d:%d\n",i,stack[i]);
}
}
int main()
{
int a,k;
for(;;)
{
printf("1:input 2:output 3:show 4: ettor \n");
scanf("%d",&a);
switch (a)
{
case 1:
printf("input value ");
scanf("%d",&a);
input(k);
break;
case 2:
output();
break;
case 3:
show();
break;
}
}
}