From 718295d782f53d32d02364b102aef467d51ef6cf Mon Sep 17 00:00:00 2001 From: iTakinn Date: Tue, 23 Jun 2026 21:37:42 -0300 Subject: [PATCH] Update cpfs.pas --- cpfs.pas | 65 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/cpfs.pas b/cpfs.pas index 9ad1940..e3328e4 100644 --- a/cpfs.pas +++ b/cpfs.pas @@ -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. \ No newline at end of file