-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRepeatVetor.pas
More file actions
43 lines (42 loc) · 985 Bytes
/
RepeatVetor.pas
File metadata and controls
43 lines (42 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//By Yure Pablo em 20/01/2016
Program RepeatVetor ; //Verifica números repetidos num vetor de inteiros
var VET,hist:array[1..50] of real; num,l,q,d:integer; p:array[1..50] of integer; n:real;
Begin
for num:=1 to 10 do
begin
writeln('Informe o valor de VET[',num,']');
readln(VET[num]);
end;
for num:=1 to 9 do
begin
for l:=num+1 to 10 do
begin
if (VET[num]=VET[l]) then
begin
p[num]:=num; p[l]:=l; n:=VET[l]; q:=q+1;
end;
end;
for d:=1 to 10 do
begin
if hist[d] = n then
q:=0;
end;
if q>0 then
begin
write(n,' se repete nas posições ');
for d:=1 to 10 do
begin
if d=p[d] then
begin
write(' -- ',p[d]:4:2);
p[d]:=0;
hist[d]:=n;
end;
end;
writeln(' ');
q:=0;
end;
end;
if n = 0 then
writeln('Não existem números repetidos no vetor.');
End.