correcao variaveis
This commit is contained in:
Vendored
+41
-41
@@ -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.
|
||||
@@ -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.
|
||||
Reference in New Issue
Block a user