Update cpfs.pas

This commit is contained in:
2026-06-23 21:37:42 -03:00
parent cd5e72a6c3
commit 718295d782
+56 -9
View File
@@ -11,6 +11,7 @@ type
var
cpf:string;
bool:boolean;
hash:thash;
@@ -36,7 +37,7 @@ function validacaoDeInexistencialismoDeOutroCadastroDePessoasFisicaDentroDaLista
else
aux:= aux^.prox;
end;
validacaoDeInexistencialismoDeOutroCadastroDePessoasFisicasDentroDaLista := existenciaDeTalInformacaoNaLista;
validacaoDeInexistencialismoDeOutroCadastroDePessoasFisicaDentroDaLista := existenciaDeTalInformacaoNaLista;
end;
@@ -62,19 +63,19 @@ function validarCPF(var cpf:string):boolean;
if (dig2 = 10) or (dig2 = 11) then
dig2 := 0;
ValidarCPF := dig1=charInt( cpf[10] ) and dig2=charInt( cpf[10] );
ValidarCPF := (dig1=charInt( cpf[10] )) and (dig2 = charInt( cpf[11] ));
end;
procedure inserirCPF(var cpfs:THash; var cpf:string);
var
i, pos:integer;
i, doisDigitos:integer;
novo, atual, ant:TCPF;
begin
if validarCPF(cpf) then
begin
doisDigitos:=( charInt(cpf[10])*10 ) + charInt(cpf[11]); //*10 pq né, vira dezena + decimal 👍
if (validacaoDeInexistencialismoDeOutroCadastroDePessoasFisicasDentroDaLista(cpf, doisDigitos, cpfs)) then
if (not validacaoDeInexistencialismoDeOutroCadastroDePessoasFisicaDentroDaLista(cpf, doisDigitos, cpfs)) then
begin
new(novo);
if novo = nil then
@@ -101,17 +102,63 @@ procedure inserirCPF(var cpfs:THash; var cpf:string);
ant^.prox := novo;
end;
end;
end
else
writeln('CPF INVALIDO');
end;
end ;
end
else
writeln('CPF INVALIDO');
end;
procedure escrever(var cpfs:thash);
var
i:integer;
aux:^ptcpf;
begin
for i:= 0 to 99 do
begin
writeln('Digito final', i);
aux := cpfs[i];
while (aux <> nil) do
begin
writeln(aux^.cpf);
aux:= aux^.prox
end;
end;
end;
procedure buscar(final:integer);
var
aux:^ptcpf;
achou:boolean;
valor:string;
begin
achou:=false;
valor:= 'Nao achou';
aux := cpfs[final];
while (aux <> nil) and (not achou) do
begin
if(aux.cpf = cpf) then
begin
achou:=true;
valor:=(aux^.cpf) ;
end;
end;
writeln(valor);
end;
procedure remover() ;
var
begin
end;
begin
readln(cpf);
inserirCPF(hash,cpf);
inserirCPF(hash, cpf);
escrever(hash);
end.