Skip to content

Instantly share code, notes, and snippets.

@valterbarros
Created May 9, 2020 23:28
Show Gist options
  • Save valterbarros/83fe7c62756e597752005dc4091f7ec6 to your computer and use it in GitHub Desktop.
Save valterbarros/83fe7c62756e597752005dc4091f7ec6 to your computer and use it in GitHub Desktop.
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