correcao variaveis

This commit is contained in:
iTakinn
2026-05-28 14:07:26 -03:00
parent 718b717222
commit 9722205161
4 changed files with 82 additions and 82 deletions
+41 -41
View File
@@ -9,44 +9,6 @@ type
THash = array[0..99] of TCPF;
procedure inserirCPF(var cpfs:THash; var cpf:string);
var
i, pos:integer;
novo, atual, ant:TCPF;
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;
function validarCPF(var cpf:string):boolean;
var
i, soma, dig1, dig2:integer;
@@ -69,13 +31,52 @@ function validarCPF(var cpf:string):boolean;
if (dig2 = 10) or (dig2 = 11) then
dig2 := 0;
ValidarCPF :=
(dig1=(Ord(cpf[10])-48)) and (dig2=(Ord(cpf[11])-48));
end;
procedure inserirCPF(var cpfs:THash; var cpf:string);
var
i, pos:integer;
novo, atual, ant:TCPF;
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:= cpfs[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 := cpfs[pos];
cpfs[pos] := novo;
end
else
begin
novo^.prox := atual;
ant^.prox := novo;
end;
end;
end
else
writeln('CPF INVALIDO');
end;
var
hash: THash;
@@ -83,6 +84,5 @@ var
bool:boolean;
begin
readln(cpf);
bool:= validarCPF(cpf);
writeln(bool);
inserirCPF(hash,cpf);
end.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+41 -41
View File
@@ -9,44 +9,6 @@ type
THash = array[0..99] of TCPF;
procedure inserirCPF(var cpfs:THash; var cpf:string);
var
i, pos:integer;
novo, atual, ant:TCPF;
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;
function validarCPF(var cpf:string):boolean;
var
i, soma, dig1, dig2:integer;
@@ -69,13 +31,52 @@ function validarCPF(var cpf:string):boolean;
if (dig2 = 10) or (dig2 = 11) then
dig2 := 0;
ValidarCPF :=
(dig1=(Ord(cpf[10])-48)) and (dig2=(Ord(cpf[11])-48));
end;
procedure inserirCPF(var cpfs:THash; var cpf:string);
var
i, pos:integer;
novo, atual, ant:TCPF;
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:= cpfs[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 := cpfs[pos];
cpfs[pos] := novo;
end
else
begin
novo^.prox := atual;
ant^.prox := novo;
end;
end;
end
else
writeln('CPF INVALIDO');
end;
var
hash: THash;
@@ -83,6 +84,5 @@ var
bool:boolean;
begin
readln(cpf);
bool:= validarCPF(cpf);
writeln(bool);
inserirCPF(hash,cpf);
end.