43 lines
1.1 KiB
Text
43 lines
1.1 KiB
Text
*process source attributed xref or(!);
|
|
annulus: procedure options (main);
|
|
/* version 1 does not handle (0/15) etc. this does. */
|
|
/* we show 1000 points here */
|
|
declare 1 point(10000),
|
|
2 x fixed binary,
|
|
2 y fixed binary;
|
|
declare (i, j, a, b, a2, b2, c) fixed binary(31);
|
|
j = 0;
|
|
do i = 1 to 1000;
|
|
r=rand(31); a=r-16;
|
|
r=rand(31); b=r-16;
|
|
a2=a*a;
|
|
b2=b*b;
|
|
c2=a2+b2;
|
|
if c2>= 100 & c2 <= 225 then
|
|
do; j = j + 1; x(j) = a; y(j) = b;
|
|
/* put Edit(a,b,c)(3(F(3))); */ end;
|
|
end;
|
|
/* PLOT */
|
|
declare table(-15:15, -15:15) character (2);
|
|
table = ' ';
|
|
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;
|
|
|
|
rand: Proc(n) Returns(Bin Fixed(31));
|
|
/*--------------------------------------------------------------------
|
|
* Return a random integer between 1 and n
|
|
*-------------------------------------------------------------------*/
|
|
Dcl r Bin Float(31);
|
|
Dcl (n,d) Bin Fixed(31);
|
|
r=random();
|
|
d=r*n+1;
|
|
Return(d);
|
|
End;
|
|
End annulus;
|