-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtestePilha.c
More file actions
59 lines (52 loc) · 1.02 KB
/
testePilha.c
File metadata and controls
59 lines (52 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include "PILHA.h"
/*NÃO É NECESSARIO CRIAR AS ESTRUTURAS PORQUE JÁ ESTÃO NA BIBLIOTE*/
Pilha* inverte(Pilha *original)
{
Pilha *aux;
aux=CriaPilha();
while(original->prim!=NULL)
{
push(aux,(pop(original)));
}
return aux;
}
int main()
{
setlocale(LC_ALL,"portuguese");
Pilha *topo;
int a;
topo= CriaPilha();
a=vazia(topo);
if(a==0)
{
printf("\n\t\t PILHA VAZIA!!!!\n\n");
}
else
{
printf("\n\t\t PILHA COM ELEMENTOS!!!!\n\n");
}
imprime (topo);
push(topo,23);
push(topo,16);
push(topo,44);
push(topo,18);
imprime (topo);
topo = inverte(topo);
imprime(topo);
/* a=pop(topo);
printf("\n\t a = %d",a);
imprime (topo);*/
topo = libera(topo);
if(!topo)
{
printf("\n\n\t\t PILHA VAZIA!!!! Não existe nem mais a estrutura\n\n");
}
else
{
printf("\n\t\t PILHA COM ELEMENTOS!!!!\n\n");
}
return 0;
}