Update cpfs.pas
This commit is contained in:
@@ -11,6 +11,7 @@ type
|
|||||||
var
|
var
|
||||||
cpf:string;
|
cpf:string;
|
||||||
bool:boolean;
|
bool:boolean;
|
||||||
|
hash:thash;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -36,7 +37,7 @@ function validacaoDeInexistencialismoDeOutroCadastroDePessoasFisicaDentroDaLista
|
|||||||
else
|
else
|
||||||
aux:= aux^.prox;
|
aux:= aux^.prox;
|
||||||
end;
|
end;
|
||||||
validacaoDeInexistencialismoDeOutroCadastroDePessoasFisicasDentroDaLista := existenciaDeTalInformacaoNaLista;
|
validacaoDeInexistencialismoDeOutroCadastroDePessoasFisicaDentroDaLista := existenciaDeTalInformacaoNaLista;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@@ -62,19 +63,19 @@ function validarCPF(var cpf:string):boolean;
|
|||||||
if (dig2 = 10) or (dig2 = 11) then
|
if (dig2 = 10) or (dig2 = 11) then
|
||||||
dig2 := 0;
|
dig2 := 0;
|
||||||
|
|
||||||
ValidarCPF := dig1=charInt( cpf[10] ) and dig2=charInt( cpf[10] );
|
ValidarCPF := (dig1=charInt( cpf[10] )) and (dig2 = charInt( cpf[11] ));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure inserirCPF(var cpfs:THash; var cpf:string);
|
procedure inserirCPF(var cpfs:THash; var cpf:string);
|
||||||
var
|
var
|
||||||
i, pos:integer;
|
i, doisDigitos:integer;
|
||||||
novo, atual, ant:TCPF;
|
novo, atual, ant:TCPF;
|
||||||
begin
|
begin
|
||||||
if validarCPF(cpf) then
|
if validarCPF(cpf) then
|
||||||
begin
|
begin
|
||||||
doisDigitos:=( charInt(cpf[10])*10 ) + charInt(cpf[11]); //*10 pq né, vira dezena + decimal 👍
|
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
|
begin
|
||||||
new(novo);
|
new(novo);
|
||||||
if novo = nil then
|
if novo = nil then
|
||||||
@@ -101,17 +102,63 @@ procedure inserirCPF(var cpfs:THash; var cpf:string);
|
|||||||
ant^.prox := novo;
|
ant^.prox := novo;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end
|
end ;
|
||||||
else
|
|
||||||
writeln('CPF INVALIDO');
|
end
|
||||||
end;
|
else
|
||||||
|
writeln('CPF INVALIDO');
|
||||||
end;
|
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
|
begin
|
||||||
readln(cpf);
|
readln(cpf);
|
||||||
inserirCPF(hash,cpf);
|
inserirCPF(hash, cpf);
|
||||||
|
escrever(hash);
|
||||||
end.
|
end.
|
||||||
Reference in New Issue
Block a user