Proszę spojrzyjcie na to.
Kod: Zaznacz cały
program colazzo;
const
n=1000;
var
t:array[1..n] of integer;
i,a,l,tom,pom:longint;
begin
tom:=0;
pom:=0;
l:=0;
i:=1;
for a:=1 to 1000 do //deklaruje powtorzenia dla roznych wartosci poczatkowych
begin
i:=1;
t[i]:=a;
l:=0;
while i<n do
begin
if ((t[i] mod 2)=0) then //definiuje ciag
t[i+1]:=t[i] div 2
else
t[i+1]:=(3*t[i]+1);
if t[i]<>1 then
begin
l:=l+1; //okreslam zachowanie "zliczacza" maksymalnych wystapien
if pom<l then
begin;
pom:=l;
tom:=a;
end;
end;
i:=i+1;
end;
l:=0;
for i:=1 to n do
writeln(t[i]);
end;
writeln();
writeln(pom);
writeln();
writeln(tom); //wyswietlenie licznika
end.