-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestaurante.c
77 lines (64 loc) · 964 Bytes
/
restaurante.c
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <stdio.h>
#include <stdlib.h>
typedef struct pilha{
int numero;
struct pilha * proximo;
}pilha;
void inserir(pilha **top){
pilha * c;
c = (pilha *)malloc(sizeof(pilha));
if(c==NULL){
printf("Sem espaço na memoria ");
exit(1);
}else{
scanf("%d",&c->numero);
if(*top==NULL){
c->proximo = NULL;
}else{
c->proximo = *top;
}
*top = c;
}
}
void listar(pilha *top){
pilha *aux;
if(top==NULL){
printf("FOME\n");
}else {
aux=top;
printf("%d\n",aux->numero);
aux = aux->proximo;
}
}
void excluir(pilha **top){
pilha *aux;
if (*top == NULL){
void listar();
}
else
{
aux = *top;
*top= aux->proximo;
}
}
int main(){
pilha * topo = NULL;
int Q, opc;
scanf("%d", &Q);
if(Q<= (10 ^7)){
do{
scanf("%d", &opc);
switch(opc){
case 1:
listar(topo);
excluir(&topo);
break;
case 2:
inserir(&topo);
break;
}
Q= Q-1;
}while(Q > 0);
}
return 0;
}