Program p181_12; { Parag 15 }
uses
   CRT, Graph;

var
  GD, GM: integer;
  c, mx, my: integer;
  x, y: longint;
BEGIN
  GD := Detect;
  InitGraph(GD, GM, '');
  if grOk <> GraphResult then begin
    writeln(' Sorry, error !');
    Halt(1);
  end;
  randomize;
  mx := getmaxx;
  my := getmaxy;
  { a) }
  rectangle(100,100,400,300);
  while not keypressed do begin
     x := random(mx);
     y := random(my);
     c := random(MaxInt);
     if not((x>100)and(x<400)and(y>100)and(y<300)) then  putpixel(x, y, c);
  end;
  ClearDevice;  CloseGraph;
  writeln('Press any key to continue . . .');readkey;

  { b) }
  InitGraph(GD, GM, '');
  circle(200,200,50);
  while not keypressed do begin
     x := random(mx);
     y := random(my);
     c := random(MaxInt);
     if sqr(x-200)+sqr(y-200)>sqr(50) then  putpixel(x, y, c);
  end;
  ClearDevice;  CloseGraph;
  writeln('Press any key to continue . . .');readkey;

  { c) }
  InitGraph(GD, GM, '');
  rectangle(0,0,100,100);
  rectangle(300,300,400,400);
  while not keypressed do begin
     x := random(mx);
     y := random(my);
     c := random(MaxInt);
     if ((x>100)or(y>100))and((x<300)or(x>400)or(y<300)or(y>400)) then  putpixel(x, y, c);
  end;
  ClearDevice;  CloseGraph;
  writeln('Press any key to continue . . .');readkey;

END.
