//editor de texto que empilha caracteres int editor_de_texto(void) { elem c, x; int erro; Pilha P; Create(&P); printf("Digite seu texto: "); while ((c=getche())!='\r') { if (c=='#') { Pop(&P,&x,&erro); if (erro) printf("(erro) "); else printf("(%c desempilhado) ",x); } else if (c=='@') { Empty(&P); printf("(pilha esvaziada) "); } else { Push(&P,&c,&erro); if (erro) printf("(erro) "); } } Inverter(&P); printf("\n\nDesempilhando tudo: "); while (!IsEmpty(&P)) { Pop(&P,&x,&erro); if (erro) printf("erro "); // else printf("%c ",x); else putchar(x); } putchar('\n'); system("pause"); return 0; }
void main (){ int i; celula *lst; //primeiro elemtento da lista - cabeça lst = malloc(sizeof(celula)); lst->seg = NULL; for(i = 0; i < 3; i++) Inserir(i, lst); for(i = 0; i < 6; i++) Inserir(i, lst); Imprimir(lst); lst->seg = Inverter(lst); printf("\n\n"); Imprimir(lst); system("pause"); getch(); }
void MainWindow::on_Inverse_clicked() { Inverter(); cenode(); }