Hi all, Can anyone explain me how is this program working. The code were wrote in Borland Turbo Pascal 7.0. Thanx to all.
---------------
program target_dartBoard;
uses Crt;
var numAnchRing, numofshoots, numPoints : byte; { number of Anchor Rings, number of shoots, number of points }
valuePoint : array[1..4] of Byte; { value of points }
i, j, k, l, m : Byte;
between1, between2, between3, between4 : Byte
totalNSol : Byte; { total number of solutions }
begin
clrscr;
totalNSol := 0;
numAnchRing := 4;
numofshoots := 5;
numPoints := 27;
valuePoint[1] := 2;
valuePoint[2] := 5;
valuePoint[3] := 7;
valuePoint[4] := 8;
between1 :=0; between2 :=0; between3 :=0; between4 :=0;
for i :=1 to pocMedz do
for j :=i to pocMedz do
for k :=j to pocMedz do
for l :=k to pocMedz do
for m :=l to pocMedz do
if (valuePoint + valuePoint[j] + valuePoint[k] + valuePoint[l] + valuePoint[m] = numPoints
then
begin
case i of
1 : Inc(between1);
2 : Inc(between2);
3 : Inc(between3);
4 : Inc(between4);
end;
case j of
1 : Inc(between1);
2 : Inc(between2);
3 : Inc(between3);
4 : Inc(between4);
end;
case k of
1 : Inc(between1);
2 : Inc(between2);
3 : Inc(between3);
4 : Inc(between4);
end;
case l of
1 : Inc(between1);
2 : Inc(between2);
3 : Inc(between3);
4 : Inc(between4);
end;
case m of
1 : Inc(between1);
2 : Inc(between2);
3 : Inc(between3);
4 : Inc(between4);
end;
Inc(totalNSol);
write(' Solution ', totalNSol, ' - (', between1, ', ', between2, ', ', between3, ', ', between4, ' )', #10#13);
between1 := 0; between2 := 0; between3 := 0; between4 := 0;
end;
repeat
until keypressed;
end.
---------------
program target_dartBoard;
uses Crt;
var numAnchRing, numofshoots, numPoints : byte; { number of Anchor Rings, number of shoots, number of points }
valuePoint : array[1..4] of Byte; { value of points }
i, j, k, l, m : Byte;
between1, between2, between3, between4 : Byte
totalNSol : Byte; { total number of solutions }
begin
clrscr;
totalNSol := 0;
numAnchRing := 4;
numofshoots := 5;
numPoints := 27;
valuePoint[1] := 2;
valuePoint[2] := 5;
valuePoint[3] := 7;
valuePoint[4] := 8;
between1 :=0; between2 :=0; between3 :=0; between4 :=0;
for i :=1 to pocMedz do
for j :=i to pocMedz do
for k :=j to pocMedz do
for l :=k to pocMedz do
for m :=l to pocMedz do
if (valuePoint + valuePoint[j] + valuePoint[k] + valuePoint[l] + valuePoint[m] = numPoints
then
begin
case i of
1 : Inc(between1);
2 : Inc(between2);
3 : Inc(between3);
4 : Inc(between4);
end;
case j of
1 : Inc(between1);
2 : Inc(between2);
3 : Inc(between3);
4 : Inc(between4);
end;
case k of
1 : Inc(between1);
2 : Inc(between2);
3 : Inc(between3);
4 : Inc(between4);
end;
case l of
1 : Inc(between1);
2 : Inc(between2);
3 : Inc(between3);
4 : Inc(between4);
end;
case m of
1 : Inc(between1);
2 : Inc(between2);
3 : Inc(between3);
4 : Inc(between4);
end;
Inc(totalNSol);
write(' Solution ', totalNSol, ' - (', between1, ', ', between2, ', ', between3, ', ', between4, ' )', #10#13);
between1 := 0; between2 := 0; between3 := 0; between4 := 0;
end;
repeat
until keypressed;
end.