correcao variaveis
This commit is contained in:
Vendored
+41
-41
@@ -9,44 +9,6 @@ type
|
|||||||
THash = array[0..99] of TCPF;
|
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;
|
function validarCPF(var cpf:string):boolean;
|
||||||
var
|
var
|
||||||
i, soma, dig1, dig2:integer;
|
i, soma, dig1, dig2:integer;
|
||||||
@@ -69,13 +31,52 @@ function validarCPF(var cpf:string):boolean;
|
|||||||
if (dig2 = 10) or (dig2 = 11) then
|
if (dig2 = 10) or (dig2 = 11) then
|
||||||
dig2 := 0;
|
dig2 := 0;
|
||||||
|
|
||||||
|
|
||||||
ValidarCPF :=
|
ValidarCPF :=
|
||||||
(dig1=(Ord(cpf[10])-48)) and (dig2=(Ord(cpf[11])-48));
|
(dig1=(Ord(cpf[10])-48)) and (dig2=(Ord(cpf[11])-48));
|
||||||
|
|
||||||
end;
|
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
|
var
|
||||||
hash: THash;
|
hash: THash;
|
||||||
@@ -83,6 +84,5 @@ var
|
|||||||
bool:boolean;
|
bool:boolean;
|
||||||
begin
|
begin
|
||||||
readln(cpf);
|
readln(cpf);
|
||||||
bool:= validarCPF(cpf);
|
inserirCPF(hash,cpf);
|
||||||
writeln(bool);
|
|
||||||
end.
|
end.
|
||||||
@@ -9,44 +9,6 @@ type
|
|||||||
THash = array[0..99] of TCPF;
|
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;
|
function validarCPF(var cpf:string):boolean;
|
||||||
var
|
var
|
||||||
i, soma, dig1, dig2:integer;
|
i, soma, dig1, dig2:integer;
|
||||||
@@ -69,13 +31,52 @@ function validarCPF(var cpf:string):boolean;
|
|||||||
if (dig2 = 10) or (dig2 = 11) then
|
if (dig2 = 10) or (dig2 = 11) then
|
||||||
dig2 := 0;
|
dig2 := 0;
|
||||||
|
|
||||||
|
|
||||||
ValidarCPF :=
|
ValidarCPF :=
|
||||||
(dig1=(Ord(cpf[10])-48)) and (dig2=(Ord(cpf[11])-48));
|
(dig1=(Ord(cpf[10])-48)) and (dig2=(Ord(cpf[11])-48));
|
||||||
|
|
||||||
end;
|
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
|
var
|
||||||
hash: THash;
|
hash: THash;
|
||||||
@@ -83,6 +84,5 @@ var
|
|||||||
bool:boolean;
|
bool:boolean;
|
||||||
begin
|
begin
|
||||||
readln(cpf);
|
readln(cpf);
|
||||||
bool:= validarCPF(cpf);
|
inserirCPF(hash,cpf);
|
||||||
writeln(bool);
|
|
||||||
end.
|
end.
|
||||||
Reference in New Issue
Block a user