#include <stdio.h>
#include <stdlib.h>
typedef struct stru
{
int num;
struct stru *prox;
} pilha;
pilha *p, *q=NULL, *top=NULL;
void push(int val)
{
p = (pilha *) malloc(sizeof(pilha));
p->num = val;
p->prox = q;
top = p;
q = p;
}
int popn()
{
p = top;
if(p == NULL) return -1;
top = p->prox;
int val = p->num;
free(p);
return val;
}
void main()
{
int n, tam=0;
while(1)
{
scanf("%d", &n);
if(n==-1) break;
printf("valor %d\n", n);
push(n);
}
printf("\n\n");
for(p=top; p!=NULL; p=p->prox, tam++);
tam --;
int lista[tam], i=0;
for(;i<=tam;i++) lista[i] = popn();
for(i=0; i<=tam; i++) printf("%d ", lista[i]);
printf("\n\nFim da pilha\n");
free(top);
}