pronto?
This commit is contained in:
@@ -12,6 +12,8 @@ var
|
|||||||
cpf:string;
|
cpf:string;
|
||||||
bool:boolean;
|
bool:boolean;
|
||||||
hash:thash;
|
hash:thash;
|
||||||
|
op : integer ;
|
||||||
|
cont : boolean ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -22,13 +24,13 @@ var tmp:integer;
|
|||||||
charInt:=tmp; //ord('0')=48... ord('1')=49... dai -48 vira 0...
|
charInt:=tmp; //ord('0')=48... ord('1')=49... dai -48 vira 0...
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function validacaoDeInexistencialismoDeOutroCadastroDePessoasFisicaDentroDaLista( var cpf:string; final:integer; var cpfs:thash ): boolean;
|
function validacaoDeInexistencialismoDeOutroCadastroDePessoasFisicaDentroDaLista( var cpf:string;var cpfs:thash ): boolean;
|
||||||
var
|
var
|
||||||
i:integer;
|
i:integer;
|
||||||
aux:^ptcpf;
|
aux:^ptcpf;
|
||||||
existenciaDeTalInformacaoNaLista:boolean;
|
existenciaDeTalInformacaoNaLista:boolean;
|
||||||
begin
|
begin
|
||||||
aux := cpfs[final];
|
aux := cpfs[(charint(cpf[10]) *10+ charint(cpf[11]))];
|
||||||
existenciaDeTalInformacaoNaLista := false;
|
existenciaDeTalInformacaoNaLista := false;
|
||||||
while (aux^.prox <> nil) and (not existenciaDeTalInformacaoNaLista) do
|
while (aux^.prox <> nil) and (not existenciaDeTalInformacaoNaLista) do
|
||||||
begin
|
begin
|
||||||
@@ -75,7 +77,7 @@ procedure inserirCPF(var cpfs:THash; var cpf:string);
|
|||||||
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 (not validacaoDeInexistencialismoDeOutroCadastroDePessoasFisicaDentroDaLista(cpf, doisDigitos, cpfs)) then
|
if (not validacaoDeInexistencialismoDeOutroCadastroDePessoasFisicaDentroDaLista(cpf, cpfs)) then
|
||||||
begin
|
begin
|
||||||
new(novo);
|
new(novo);
|
||||||
if novo = nil then
|
if novo = nil then
|
||||||
@@ -126,7 +128,7 @@ procedure escrever(var cpfs:thash);
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure buscar(final:integer);
|
procedure buscar(var cpfs:thash;cpf:string);
|
||||||
var
|
var
|
||||||
aux:^ptcpf;
|
aux:^ptcpf;
|
||||||
achou:boolean;
|
achou:boolean;
|
||||||
@@ -134,31 +136,111 @@ procedure buscar(final:integer);
|
|||||||
begin
|
begin
|
||||||
achou:=false;
|
achou:=false;
|
||||||
valor:= 'Nao achou';
|
valor:= 'Nao achou';
|
||||||
aux := cpfs[final];
|
aux := cpfs[ (charint(cpf[10]) *10+ charint(cpf[11])) ];
|
||||||
while (aux <> nil) and (not achou) do
|
while (aux <> nil) and (not achou) do
|
||||||
begin
|
begin
|
||||||
if(aux.cpf = cpf) then
|
if(aux^.cpf = cpf) then
|
||||||
begin
|
begin
|
||||||
achou:=true;
|
achou:=true;
|
||||||
valor:=(aux^.cpf) ;
|
valor:=(aux^.cpf) ;
|
||||||
end;
|
end
|
||||||
|
else
|
||||||
|
aux:= aux^.prox;
|
||||||
end;
|
end;
|
||||||
writeln(valor);
|
writeln(valor);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure remover() ;
|
procedure removerCPF(var cpfs:thash;cpf:string) ;
|
||||||
var
|
var
|
||||||
|
aux:^ptcpf;
|
||||||
|
aux2:^ptcpf;
|
||||||
|
achou:boolean;
|
||||||
|
begin
|
||||||
|
achou:=false;
|
||||||
|
aux := cpfs[ (charint(cpf[10]) *10+ charint(cpf[11])) ];
|
||||||
|
while (aux <> nil) and (not achou) do
|
||||||
|
begin
|
||||||
|
if(aux^.cpf = cpf) then
|
||||||
|
begin
|
||||||
|
achou:=true;
|
||||||
|
aux2:=(aux^.prox) ;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
aux:= aux^.prox
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
procedure cpfsInicializar ( var cpfs : thash ) ;
|
||||||
|
var
|
||||||
|
i : integer ;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
for i := 0 to 99 do
|
||||||
|
cpfs[i] := nil ;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
readln(cpf);
|
cont := false ;
|
||||||
|
op := 1 ;
|
||||||
|
cpfsInicializar(hash) ;
|
||||||
|
while not cont do
|
||||||
|
begin
|
||||||
|
|
||||||
|
writeln('ADD cpf : 1');
|
||||||
|
writeln('Validar existencia : 2');
|
||||||
|
writeln('RM cpf : 3');
|
||||||
|
writeln('exit : 0');
|
||||||
|
readln(op);
|
||||||
|
|
||||||
|
case op of
|
||||||
|
1 :
|
||||||
|
begin
|
||||||
|
writeln('Digite o cpf a ser inserido');
|
||||||
|
readln(cpf) ;
|
||||||
|
if (validarCPF(cpf)) then
|
||||||
|
begin
|
||||||
inserirCPF(hash, cpf);
|
inserirCPF(hash, cpf);
|
||||||
escrever(hash);
|
writeln('inserido');
|
||||||
|
end
|
||||||
|
else
|
||||||
|
writeln('cpf invalido poxa');
|
||||||
|
end;
|
||||||
|
|
||||||
|
2 :
|
||||||
|
begin
|
||||||
|
writeln('Digite o cpf a ser validado a existencia');
|
||||||
|
readln(cpf) ;
|
||||||
|
if (validarCPF(cpf)) then
|
||||||
|
begin
|
||||||
|
if validacaoDeInexistencialismoDeOutroCadastroDePessoasFisicaDentroDaLista(cpf,hash) then
|
||||||
|
writeln('está na lista já')
|
||||||
|
else
|
||||||
|
writeln('num tá');
|
||||||
|
end
|
||||||
|
else
|
||||||
|
writeln('cpf invalido poxa');
|
||||||
|
end;
|
||||||
|
|
||||||
|
3:
|
||||||
|
begin
|
||||||
|
writeln('Digite o cpf a ser removido');
|
||||||
|
readln(cpf) ;
|
||||||
|
if (validarCPF(cpf)) then
|
||||||
|
begin
|
||||||
|
removerCPF(hash, cpf);
|
||||||
|
writeln('removido');
|
||||||
|
end
|
||||||
|
else
|
||||||
|
writeln('cpf invalido poxa');
|
||||||
|
end;
|
||||||
|
|
||||||
|
0 :
|
||||||
|
begin
|
||||||
|
cont:= true;
|
||||||
|
end;
|
||||||
|
else
|
||||||
|
writeln('opção invalidade ');
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end.
|
end.
|
||||||
Reference in New Issue
Block a user