Created
May 9, 2020 23:28
-
-
Save valterbarros/83fe7c62756e597752005dc4091f7ec6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Program cartas; | |
type | |
carta = record | |
nipe:string; | |
numero:integer; | |
prox:^carta; | |
end; | |
var | |
topo:^carta; | |
aux:carta; | |
i:integer; | |
FUNCTION insere(topoPilha:carta; novaCarta:carta):carta; | |
Begin | |
novaCarta.prox := @topoPilha; | |
insere := novaCarta; | |
end; | |
FUNCTION remove(topoPilha:carta):carta; | |
Begin | |
remove := topoPilha.prox^; | |
end; | |
Procedure acessaTopo(topoPilha:carta); | |
Begin | |
writeln(topoPilha.nipe); | |
writeln(topoPilha.numero); | |
end; | |
Begin | |
//inicializa a pilha | |
topo := nil; | |
//Cria um registro | |
aux.nipe := 'ouro'; | |
aux.numero := 10; | |
//Insere o primeiro registro | |
aux := insere(topo^,aux); | |
topo := @aux; | |
//Acessa o promeiro registro | |
acessaTopo(topo^); | |
readln(i); | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment