Constrained random points on a circle: Difference between revisions

Line 1,224:
# # #
# # #</pre>
 
=={{header|PL/I}}==
<lang PL/I>
constrain: procedure options (main);
declare 1 point (100),
2 x fixed binary,
2 y fixed binary;
declare (i, j, a, b, c) fixed binary;
 
j = 0;
do i = 1 to 100;
a = 30*random()-15; b = 30*random()-15;
c = sqrt(a**2 + b**2);
if abs(c) >= 10 & abs(c) <= 15 then
do; j = j + 1; x(j) = a; y(j) = b; end;
end;
 
/* PLOT */
declare table(-15:15, -15:15) character (1);
do i = 1 to j;
table(x(i), y(i)) = '*';
end;
do i = -15 to 15;
put skip;
do j = -15 to 15;
put edit (table(i,j)) (a);
end;
end;
end constrain;
</lang>
Output:
<pre>
** *
* *
**
**
*
***
*
*
**
*
* **
* *
** *
* *
***
***
***
*
*
</pre>
 
=={{header|Prolog}}==
Anonymous user