Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pleasee HELP - How it works?

Status
Not open for further replies.

cervena

Technical User
Dec 15, 2004
1
SK
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.

 
It might help if you ask a more specific question regarding what you are confused about.
 
do you want to know what the program does, or how it actually runs, so what hapens, i.e i does this, so that j does that causing n to terminate?

joey
 
it looks like a scoring proc or solut for a game.if you want to see how exactly it works you must find the other papt of the source,because this part is a bit unclear
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top