This commit is contained in:
iTakinn
2026-05-28 13:40:53 -03:00
parent 4c4471ca1a
commit 718b717222
4 changed files with 95 additions and 8 deletions
+8
View File
@@ -0,0 +1,8 @@
teste
teste.o
.vscode/GTEMP.pas
cpfs.o
cpfs
GPATH
GRTAGS
GTAGS
+36 -4
View File
@@ -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
+36 -4
View File
@@ -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
+15
View File
@@ -0,0 +1,15 @@
program tkn;
uses SysUtils;
var
cpf: string;
last: integer;
begin
cpf := '12345678912';
last := (Ord(cpf[10])-Ord('0'))*10+(Ord(cpf[11])-Ord('0'));
writeln(last);
end.