Скачиваний:
53
Добавлен:
10.12.2013
Размер:
10.63 Кб
Скачать
program GSA; { Џ®бв஥­ЁҐ ўҐвўпйЁебп ўлзЁб«ЁвҐ«м­ле Їа®жҐбб®ў }
uses crt,graph;
var driver,mode:integer; { „«п Ё­ЁжЁ «Ё§ жЁЁ Ја дЁЄЁ }
    err:integer; { Љ®¤ ®иЁЎЄЁ ЇаЁ Ё­ЁжЁ «Ё§ жЁЁ Ја дЁЄЁ }
    x0,y0:integer; { Љ®®а¤Ё­ вл ᬥ饭Ёп ­г«п Ја дЁЄ  }
    k:integer; { Љ®®дЁжЁҐ­в 㢥«ЁзҐ­Ёп Ја дЁЄ  дг­ЄжЁЁ }
    x,y:real; { ‚бЇ®¬®Ј вҐ«м­лҐ ЇҐаҐ¬Ґ­­лҐ }
    kt,t,i,j:integer; { ‚бЇ®¬®Ј вҐ«м­лҐ ЇҐаҐ¬Ґ­­лҐ }
    st,st1:string; { ‚бЇ®¬®Ј вҐ«м­лҐ бва®ЄЁ }
    c:char; { „«п з⥭Ёп Є®¤  Є« ўЁи }
    mx:array[1..20] of real; { Љ®®а¤Ё­ вл x, ўў®¤Ё¬ле в®зҐЄ }
    my:array[1..20] of real; { Љ®®а¤Ё­ вл y, ўў®¤Ё¬ле в®зҐЄ }
    nom:array[1..20] of integer; { Ќ®¬Ґа  ®Ў« б⥩ ў Є®в®алҐ Ї®Ї ¤ «Ё в®зЄЁ }
    nom1:integer; { Ќ®¬Ґа ®Ў« бвЁ, ў Є®в®аго ­г¦­® Ї®Ї бвм в®зЄ®©  }
    tn:integer; { Љ®«ЁзҐбвў® в®зҐЄ ®Ўа Ў влў Ґ¬ле Їа®жҐ¤га®© popal }

PROCEDURE draw;  { ------------- ЏђЋ–…„“ђЂ -------------- }
  begin
cleardevice;
{ Ќ е®¤Ё¬ бҐаҐ¤Ё­г нЄа ­  }
x0:=getmaxx div 2;
y0:=getmaxy div 2;
{ ‡ ¤ Ґ¬ Є®®дЁжЁҐ­в 㢥«ЁзҐ­Ёп Ја дЁЄ  дг­ЄжЁЁ   }
k:=25;

{ ђЁб㥬 ®бЁ }
setbkcolor(black);
setcolor(white);
line(x0,0,x0,getmaxy);
line(0,y0,getmaxx,y0);
{ ђЁб㥬 ба⥫ЄЁ Є Є®­ж ¬ ®бҐ© }
line(x0,0,x0-3,7);
line(x0,0,x0+3,7);
line(getmaxx-7,y0-3,getmaxx,y0);
line(getmaxx-7,y0+3,getmaxx,y0);
{ ђЁб㥬 а §«Ё­®ўЄг ®бҐ© }
t:=0;
repeat
t:=t+k;
line(x0+t,y0-2,x0+t,y0+2);
line(x0-t,y0-2,x0-t,y0+2);
line(x0-2,y0-t,x0+2,y0-t);
line(x0-2,y0+t,x0+2,y0+t);
until t>x0-k;

{           ђЁб㥬 ­ҐбЄ®«мЄ® дЁЈга :           }
setcolor(white);

{ Џ а Ў®«    y=0.5*sqr(x)-8 }
x:=0; moveto(x0,y0+8*k);     { аЁб㥬 Їа ўго Ї®«®ўЁ­г Ї а Ў®«л }
repeat
y:=0.5*sqr(x)-8;
lineto(round(k*x)+x0,round(-k*y)+y0);
x:=x+0.01;
until (-y*k+y0)<0;

x:=0; moveto(x0,y0+8*k);     { аЁб㥬 «Ґўго Ї®«®ўЁ­г Ї а Ў®«л }
repeat
y:=0.5*sqr(x)-8;
lineto(round(k*x)+x0,round(-k*y)+y0);
x:=x-0.01;
until (-y*k+y0)<0;

{ ЋЄаг¦­®бвм     sqr(x)+sqr(y)=sqr(8) }
circle(x0,y0,8*k);

{ Џап¬ п         y=x-2  }
x:=-30;
repeat
y:=x-2;
putpixel(round(k*x)+x0,round(-k*y)+y0,white);
x:=x+0.01;
until (-k*x+x0)<0;
  end;

PROCEDURE popal; { ------------- ЏђЋ–…„“ђЂ -------------- }
  begin
{ Џа®ўҐа塞 ў Є Єго ®Ў« бвм Ї®Ї «Ё в®зЄЁ }
for i:=1 to tn do
   begin

if (mx[i]<0) and (my[i]>0) and (sqr(my[i])>(64-sqr(mx[i]))) and (sqr(mx[i])>(2*my[i]+16))
then begin
nom[i]:=1;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;

if (mx[i]<0) and (sqr(my[i])>(64-sqr(mx[i]))) and (sqr(mx[i])<(2*my[i]+16))
then begin
nom[i]:=2;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;

if (mx[i]>0) and (sqr(my[i])>(64-sqr(mx[i]))) and (sqr(mx[i])<(2*my[i]+16))
then begin
nom[i]:=3;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;

if (mx[i]>0) and (my[i]>0) and (sqr(my[i])>(64-sqr(mx[i]))) and (sqr(mx[i])>(2*my[i]+16)) and (my[i]>mx[i]-2)
then begin
nom[i]:=4;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;

if (mx[i]>0) and (my[i]>0) and (sqr(my[i])>(64-sqr(mx[i]))) and (sqr(mx[i])>(2*my[i]+16)) and (my[i]<mx[i]-2)
then begin
nom[i]:=5;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;

if (mx[i]<0) and (my[i]>0) and (sqr(my[i])<(64-sqr(mx[i]))) and (sqr(mx[i])>(2*my[i]+16))
then begin
nom[i]:=6;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;


if (mx[i]<0) and (my[i]>0) and (sqr(my[i])<(64-sqr(mx[i]))) and (sqr(mx[i])<(2*my[i]+16))
then begin
nom[i]:=7;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;

if (mx[i]>0) and (my[i]>0) and (sqr(my[i])<(64-sqr(mx[i]))) and (sqr(mx[i])<(2*my[i]+16)) and (my[i]>mx[i]-2)
then begin
nom[i]:=8;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;

if (mx[i]>0) and (my[i]>0) and (sqr(my[i])<(64-sqr(mx[i]))) and (sqr(mx[i])>(2*my[i]+16)) and (my[i]>mx[i]-2)
then begin
nom[i]:=9;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;

if (mx[i]>0) and (my[i]>0) and (sqr(my[i])<(64-sqr(mx[i]))) and (sqr(mx[i])<(2*my[i]+16)) and (my[i]<mx[i]-2)
then begin
nom[i]:=10;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;

if (mx[i]>0) and (my[i]>0) and (sqr(my[i])<(64-sqr(mx[i]))) and (sqr(mx[i])>(2*my[i]+16)) and (my[i]<mx[i]-2)
then begin
nom[i]:=21;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;

if (mx[i]<0) and (my[i]<0) and (sqr(my[i])>(64-sqr(mx[i]))) and (my[i]>mx[i]-2)
then begin
nom[i]:=11;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;

if (mx[i]<0) and (my[i]<0) and (sqr(my[i])<(64-sqr(mx[i]))) and (sqr(mx[i])>(2*my[i]+16)) and (my[i]>mx[i]-2)
then begin
nom[i]:=12;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;

if (mx[i]<0) and (my[i]<0) and (sqr(my[i])<(64-sqr(mx[i]))) and (sqr(mx[i])<(2*my[i]+16)) and (my[i]>mx[i]-2)
then begin
nom[i]:=13;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;

if (mx[i]>0) and (my[i]<0) and (my[i]>mx[i]-2)
then begin
nom[i]:=14;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;

if (mx[i]>0) and (my[i]<0) and (sqr(my[i])<(64-sqr(mx[i]))) and (sqr(mx[i])<(2*my[i]+16)) and (my[i]<mx[i]-2)
then begin
nom[i]:=15;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;

if (mx[i]>0) and (my[i]<0) and (sqr(my[i])<(64-sqr(mx[i]))) and (sqr(mx[i])>(2*my[i]+16))
then begin
nom[i]:=16;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;

if (mx[i]>0) and (my[i]<0) and (sqr(my[i])>(64-sqr(mx[i])))
then begin
nom[i]:=17;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;

if (mx[i]<0) and (my[i]<0) and (sqr(my[i])>(64-sqr(mx[i]))) and (my[i]<mx[i]-2)
then begin
nom[i]:=18;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;

if (mx[i]<0) and (my[i]<0) and (sqr(my[i])<(64-sqr(mx[i]))) and (sqr(mx[i])>(2*my[i]+16)) and (my[i]<mx[i]-2)
then begin
nom[i]:=19;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;

if (mx[i]<0) and (my[i]<0) and (sqr(mx[i])<(2*my[i]+16)) and (my[i]<mx[i]-2)
then begin
nom[i]:=20;
setfillstyle(1,i);
floodfill(x0+round(mx[i]*k),y0-round(my[i]*k),white);
     end;
   end;
{ ‘в ўЁ¬ Єа б­го в®зЄг ў ⮬ ¬ҐбвҐ, Єг¤  гЄ § «Ё Є®®а¤Ё­ в ¬Ё }
putpixel(x0+round(mx[i]*k),y0-round(my[i]*k),13);

  end;

PROCEDURE nomer;  { ------------- ЏђЋ–…„“ђЂ -------------- }
  begin
 { Ќ®¬Ґа㥬 ®Ў« бвЁ }
setcolor(red);
outtextxy(x0-10*k,y0-5*k,'1');
outtextxy(x0-3*k,y0-round(8.5*k),'2');
outtextxy(x0+3*k,y0-round(8.5*k),'3');
outtextxy(x0+7*k,y0-8*k,'4');
outtextxy(x0+10*k,y0-5*k,'5');
outtextxy(x0-6*k,y0-3*k,'6');
outtextxy(x0-2*k,y0-5*k,'7');
outtextxy(x0+2*k,y0-5*k,'8');
outtextxy(x0+round(5.5*k),y0-round(4.8*k),'9');
outtextxy(x0+round(5.5*k),y0-round(4.8*k),'9');
outtextxy(x0+round(3.3*k),y0-k,'10');
outtextxy(x0-10*k,y0+5*k,'11');
outtextxy(x0-6*k,y0+2*k,'12');
outtextxy(x0-round(2.5*k),y0+round(1.5*k),'13');
outtextxy(x0+round(0.3*k),y0+round(0.5*k),'14');
outtextxy(x0+2*k,y0+round(1.5*k),'15');
outtextxy(x0+5*k,y0+2*k,'16');
outtextxy(x0+10*k,y0+5*k,'17');
outtextxy(x0-round(3.5*k),y0+round(8.3*k),'18');
outtextxy(x0-round(3.1*k),y0+round(6.2*k),'19');
outtextxy(x0-round(1.4*k),y0+5*k,'20');
outtextxy(x0+round(6*k),y0-2*k,'21');

{ Ќ®¬Ґа жЁп Є®®а¤Ё­ в ®бҐ© }
setcolor(7);
settextstyle(2,0,3);
t:=0; i:=0;
repeat
t:=t+k; i:=i+1;
str(i,st);
outtextxy (x0+t-1,y0+3,st);
st:='-'+st;
outtextxy (x0-t-7,y0+3,st);
str(i,st);
outtextxy (x0-8,y0-t-4,st);
st:='-'+st;
outtextxy (x0-12,y0+t-4,st);
until t>x0-k;
settextstyle(0,0,1);

  end;


PROCEDURE probel;  { ------------- ЏђЋ–…„“ђЂ -------------- }
  begin
{ Ћ¦Ё¤ ­ЁҐ ­ ¦ вЁп Їа®ЎҐ«  }
repeat
c:=#5;
if keypressed then c:=readkey;
 setcolor(random(14)+1);
outtextxy(0,getmaxy-8,'Ќ ¦¬ЁвҐ Їа®ЎҐ« ¤«п Їа®¤®«¦Ґ­Ёп !');
 delay(50);
until c=#32;

  end;

BEGIN  { --------------- ЌЂ—Ђ‹Ћ ЏђЋѓђЂЊЊ› ---------------- }
randomize;
{ ‚лЎЁа Ґ¬ ०Ё¬ а Ў®вл }
clrscr;
textcolor(3);
writeln(' ‚лЎҐаЁвҐ вЁЇ ®Ўа Ў®вЄЁ ¤ ­­ле: ');
writeln('    (1) Џ® Є®®а¤Ё­ в ¬.         ');
writeln('    (2) Џ® ­®¬Ґаг ®Ў« бвЁ Ё     ');
writeln('           Є®®а¤Ё­ в ¬.         ');
readln(kt);
{ €­ЁжЁ «Ё§ жЁЁ Ја дЁЄЁ }
driver:=0;
initgraph(driver,mode,'c:\BPASKAL\bgi');
err:=graphresult;
if err<>0 then begin
               writeln('ЋиЁЎЄ  Ја дЁЄЁ : ',grapherrormsg(err));
               halt;
               end;
 draw; nomer;
if kt=1 then begin
setcolor(green);
textcolor(green);
outtextxy(0,20,'‚ўҐ¤ЁвҐ Є®«ЁзҐбвў® в®зҐЄ (1-15):');
gotoxy(33,2);
read(tn);
{ ‚ў®¤Ё¬ tn в®зҐЄ }
for j:=1 to tn do begin

repeat
 draw; nomer;
setcolor(white);
textcolor(white);
str(j,st);
st1:='Љ®®а¤Ё­ вл '+st+' в®зЄЁ';
outtextxy(0,10,st1);
gotoxy(4,3);
outtextxy(0,35,'X=');
read(mx[j]);
 draw; nomer;
setcolor(white);
textcolor(white);
outtextxy(0,10,st1);
outtextxy(0,35,'Y=');
gotoxy(4,3);
read(my[j]);
setcolor(red);
if mx[j]<-12 then begin outtextxy(50,50,'‚ўҐ¤ЁвҐ x Ї®Ў®«миҐ !'); probel end;
if my[j]<-9 then begin outtextxy(50,60,'‚ўҐ¤ЁвҐ y Ї®Ў®«миҐ !'); probel end;
if mx[j]>12 then begin outtextxy(50,70,'‚ўҐ¤ЁвҐ x Ї®¬Ґ­миҐ !'); probel end;
if my[j]>9  then begin outtextxy(50,80,'‚ўҐ¤ЁвҐ y Ї®¬Ґ­миҐ !'); probel end;
until  (mx[j]>-13) and (mx[j]<13) and  (my[j]>-10) and (my[j]<10) ;
                end;
draw;
 popal;
  nomer;
   probel;
        end;

if kt=2 then begin
 draw; nomer;
setcolor(green);
textcolor(green);
outtextxy(0,20,'‚ўҐ¤ЁвҐ ­®¬Ґа ®Ў« бвЁ (®в 1 ¤® 20) ');
gotoxy(36,2);
readln(nom1);
 draw; nomer;
setcolor(white);
textcolor(white);
outtextxy(0,20,'‚ўҐ¤ЁвҐ Є®®а¤Ё­ вл в®зЄЁ ');
gotoxy(4,3);
outtextxy(0,35,'X=');
read(mx[1]);
 draw; nomer;
outtextxy(0,20,'‚ўҐ¤ЁвҐ Є®®а¤Ё­ вл в®зЄЁ ');
outtextxy(0,35,'Y=');
gotoxy(4,3);
read(my[1]);
tn:=1;
 draw;
  popal;
   nomer;
settextstyle(0,0,2);
setcolor(3);
if nom1=nom[1] then begin
                    outtextxy(5,7,'Џ®Ї « !!!');
                    sound(500);
                    delay(1000);
                    nosound;
                    end
                     else  outtextxy(5,7,'ЊЁ¬® !');
settextstyle(0,0,1);
probel;
            end;
END.
Соседние файлы в папке ЭВТ-1-Паскаль