#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
typedef struct cel {
char conteudo;
struct cel *prox;
} celula;
typedef struct pilha {
struct cel *cabeca;
} pilha;
void empilha(char c, pilha *p) {
celula
*nova
= malloc(sizeof(celula
)); nova->conteudo = c;
nova->prox = p->cabeca;
p->cabeca = nova;
}
char desempilha(pilha *p) {
celula *pt = p->cabeca;
char c = pt->conteudo;
p->cabeca = pt->prox;
return c;
}
int main() {
char frase[50];
pilha p;
p.cabeca = NULL;
for (int i = 0; frase[i] != '\0'; i++) {
empilha(frase[i], &p);
}
while (p.cabeca != NULL) {
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPG1hbGxvYy5oPgoKdHlwZWRlZiBzdHJ1Y3QgY2VsIHsKICAgIGNoYXIgY29udGV1ZG87CiAgICBzdHJ1Y3QgY2VsICpwcm94Owp9IGNlbHVsYTsKCnR5cGVkZWYgc3RydWN0IHBpbGhhIHsKICAgIHN0cnVjdCBjZWwgKmNhYmVjYTsKfSBwaWxoYTsKCnZvaWQgZW1waWxoYShjaGFyIGMsIHBpbGhhICpwKSB7CiAgICBjZWx1bGEgKm5vdmEgPSBtYWxsb2Moc2l6ZW9mKGNlbHVsYSkpOwogICAgbm92YS0+Y29udGV1ZG8gPSBjOwogICAgbm92YS0+cHJveCA9IHAtPmNhYmVjYTsKICAgIHAtPmNhYmVjYSA9IG5vdmE7Cn0KCmNoYXIgZGVzZW1waWxoYShwaWxoYSAqcCkgewogICAgY2VsdWxhICpwdCA9IHAtPmNhYmVjYTsKICAgIGNoYXIgYyA9IHB0LT5jb250ZXVkbzsKICAgIHAtPmNhYmVjYSA9IHB0LT5wcm94OwogICAgZnJlZShwdCk7CiAgICByZXR1cm4gYzsKfQoKaW50IG1haW4oKSB7CiAgICBjaGFyIGZyYXNlWzUwXTsKICAgIHBpbGhhIHA7CiAgICBwLmNhYmVjYSA9IE5VTEw7CiAgICBwc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