Task

Generate 100 <x,y> coordinate pairs such that x and y are integers sampled from the uniform distribution with the condition that 




10
≤



x

2


+

y

2




≤
15


{\displaystyle 10\leq {\sqrt {x^{2}+y^{2}}}\leq 15}

. 
Then display/plot them. The outcome should be a "fuzzy" circle. The actual number of points plotted may be less than 100, given that some pairs may be generated more than once.

There are several possible approaches to accomplish this. Here are two possible algorithms.

1) Generate random pairs of integers and filter out those that don't satisfy this condition:





10
≤



x

2


+

y

2




≤
15


{\displaystyle 10\leq {\sqrt {x^{2}+y^{2}}}\leq 15}

.
2) Precalculate the set of all possible points (there are 404 of them) and select randomly from this set.




PROC clrscr = VOID: 
        printf(($g"[2J"$,REPR 27)); # ansi.sys #
 
PROC gotoxy = (INT x,y)VOID: 
        printf(($g"["g(0)";"g(0)"H"$,REPR 27, y,x)); # ansi.sys #
 
MODE POINT = STRUCT(
    INT x,y
);
 
INT radius = 15;
INT inside radius = 10;
 
POINT center = (radius+1, radius+1);
 
FLEX[0]POINT set;
 
PROC swap with last set = (INT position,INT where last set)VOID:
(
        INT temp := x OF set[position];
        x OF set[position]:=x OF set[where last set];
        x OF set[where last set] := temp;
 
        temp := y OF set[position];
        y OF set[position]:=y OF set[where last set];
        y OF set[where last set] := temp
);
 
PROC create set = VOID:
(
        set := HEAP[(2*radius+1)**2]POINT;
        INT x,y,i:=LWB set;
 
        FOR x FROM -radius TO radius DO
                FOR y FROM -radius TO radius DO
                        IF sqrt(x*x+y*y)>=inside radius AND sqrt(x*x+y*y)<=radius THEN
                                x OF set[i] := x;
                                y OF set[i] := y;
                                i+:=1
                        FI
                OD
        OD;
 
        set:=set[:i-1]
);
 
PROC plot fuzzy set = (CHAR ch)VOID:
(
        INT pos,i;
 
        TO UPB set DO
                pos := ENTIER(random * UPB set) + 1;
 
                gotoxy(x OF center + x OF set[pos],y OF center + y OF set[pos]);
 
                print(ch);
 
                swap with last set(pos,UPB set)
 
        OD
);
 
main:
(
        # srand((INT)time(NIL)); #
 
        clrscr;
        create set;
        plot fuzzy set("*");
        gotoxy(2*radius+1, 2*radius+1);
        newline(stand in)
)