takin
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
teste
|
||||||
|
teste.o
|
||||||
|
.vscode/GTEMP.pas
|
||||||
|
cpfs.o
|
||||||
|
cpfs
|
||||||
|
GPATH
|
||||||
|
GRTAGS
|
||||||
|
GTAGS
|
||||||
Vendored
+36
-4
@@ -6,13 +6,45 @@ type
|
|||||||
cpf : string;
|
cpf : string;
|
||||||
prox : TCPF;
|
prox : TCPF;
|
||||||
end;
|
end;
|
||||||
|
THash = array[0..99] of TCPF;
|
||||||
|
|
||||||
|
|
||||||
procedure inserirCPF();
|
procedure inserirCPF(var cpfs:THash; var cpf:string);
|
||||||
var
|
var
|
||||||
i:integer;
|
i, pos:integer;
|
||||||
|
novo, atual, ant:TCPF;
|
||||||
begin
|
begin
|
||||||
|
if validarCPF(cpf) then
|
||||||
|
begin
|
||||||
|
pos:=(Ord(cpf[10])-48)*10 + (Ord(cpf[11])-48); //esse ngocio pega os digitos verificadores, gpt ajudou, transformar string em int é pesadelo
|
||||||
|
new(novo);
|
||||||
|
if novo = nil then
|
||||||
|
writeln('Memoria cheia');
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
novo^.cpf := cpf;
|
||||||
|
novo^.prox := nil;
|
||||||
|
atual:= hash[pos];
|
||||||
|
ant:=nil
|
||||||
|
while (atual <> nil) and (atual^.cpf < cpf) do
|
||||||
|
begin
|
||||||
|
ant := atual;
|
||||||
|
atual := atual^.prox;
|
||||||
|
end;
|
||||||
|
if ant = nil then
|
||||||
|
begin
|
||||||
|
novo^.prox := hash[pos];
|
||||||
|
hash[pos] := novo;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
novo^.prox := atual;
|
||||||
|
ant^.prox := novo;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
writeln('CPF INVALIDO');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function validarCPF(var cpf:string):boolean;
|
function validarCPF(var cpf:string):boolean;
|
||||||
@@ -46,7 +78,7 @@ function validarCPF(var cpf:string):boolean;
|
|||||||
|
|
||||||
|
|
||||||
var
|
var
|
||||||
hash : array[0..99] of TCPF;
|
hash: THash;
|
||||||
cpf:string;
|
cpf:string;
|
||||||
bool:boolean;
|
bool:boolean;
|
||||||
begin
|
begin
|
||||||
|
|||||||
@@ -6,13 +6,45 @@ type
|
|||||||
cpf : string;
|
cpf : string;
|
||||||
prox : TCPF;
|
prox : TCPF;
|
||||||
end;
|
end;
|
||||||
|
THash = array[0..99] of TCPF;
|
||||||
|
|
||||||
|
|
||||||
procedure inserirCPF();
|
procedure inserirCPF(var cpfs:THash; var cpf:string);
|
||||||
var
|
var
|
||||||
i:integer;
|
i, pos:integer;
|
||||||
|
novo, atual, ant:TCPF;
|
||||||
begin
|
begin
|
||||||
|
if validarCPF(cpf) then
|
||||||
|
begin
|
||||||
|
pos:=(Ord(cpf[10])-48)*10 + (Ord(cpf[11])-48); //esse ngocio pega os digitos verificadores, gpt ajudou, transformar string em int é pesadelo
|
||||||
|
new(novo);
|
||||||
|
if novo = nil then
|
||||||
|
writeln('Memoria cheia');
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
novo^.cpf := cpf;
|
||||||
|
novo^.prox := nil;
|
||||||
|
atual:= hash[pos];
|
||||||
|
ant:=nil
|
||||||
|
while (atual <> nil) and (atual^.cpf < cpf) do
|
||||||
|
begin
|
||||||
|
ant := atual;
|
||||||
|
atual := atual^.prox;
|
||||||
|
end;
|
||||||
|
if ant = nil then
|
||||||
|
begin
|
||||||
|
novo^.prox := hash[pos];
|
||||||
|
hash[pos] := novo;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
novo^.prox := atual;
|
||||||
|
ant^.prox := novo;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
writeln('CPF INVALIDO');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function validarCPF(var cpf:string):boolean;
|
function validarCPF(var cpf:string):boolean;
|
||||||
@@ -46,7 +78,7 @@ function validarCPF(var cpf:string):boolean;
|
|||||||
|
|
||||||
|
|
||||||
var
|
var
|
||||||
hash : array[0..99] of TCPF;
|
hash: THash;
|
||||||
cpf:string;
|
cpf:string;
|
||||||
bool:boolean;
|
bool:boolean;
|
||||||
begin
|
begin
|
||||||
|
|||||||
Reference in New Issue
Block a user