в проге 2 задачи с меню.
Относительно этой системы координат
x0:=-xm div 2 +boundx;
y0:=-ym div 2-boundy;
задаю
коодинаты 5тиугольника
line(-150,150,150,150);
line(-150,150,-200,0);
line(-200,0,0,-150);
line(0,-150,200,0);
line(200,0,150,150);
систуму ввела,координаты ввела,а площаль вычислять не хочет!!!
Помогите исправить Пожалуйста!!!
Код: Выделить всё
Program Individualnaya;
Uses crt,graph;
label 1,2,3,4,5;
const Menu:array[1..3] of string[17]=('Zadacha 1','Zadacha 2','Vyhod');
boundx=16;
boundy=12;
Var
i,j,k:integer;
kx,ky,xm,ym,n,m,x,y,x0,y0:longint;
hx,hy,p,a,b,ymin,ymax:real;
s,p1,m1:string;
c:char;
gd,gm:integer;
begin
i:=0;
initgraph(i,i,'i:\');
SetGraphMode(1);
SetFillStyle(0,10);
FloodFill(0,0,15);
SetTextStyle(0,0,2);
SetColor(11);
Rectangle(50,50,550,340);
Outtextxy(80,80,'Individualnaya rabota');
Outtextxy(80,100,'po programmirovaniu');
SetColor(15);
Outtextxy(80,160,'Vypolnila:');
SetColor(10);
Outtextxy(80,180,'Studentka ');
Outtextxy(80,200,'M.N.');
SetColor(15);
Outtextxy(80,220,'Proveril:');
SetColor(10);
Outtextxy(80,240,'V.K.');
readln;
clrscr;
5:
SetGraphMode(1);
SetBkColor(4);
FloodFill(0,0,3);
SetTextStyle(0,0,2);
For i:=1 to 3 do Outtextxy(210,20+20*i,Menu[i]);
j:=1;
repeat
SetColor(14); {tsvet bykv pri vibore zada4i}
Outtextxy(210,20+20*j,Menu[j]);
c:=readkey;
If c=#0 then begin
c:=readkey;
SetColor(4);
Outtextxy(210,20+20*j,Menu[j]);
If c=#72 then dec(j);
If c=#80 then inc(j);
If j>3 then j:=1;
If j<1 then j:=3;
end;
Until c=#13;
If j=1 then goto 1;
If j=2 then goto 2;
If j=3 then goto 3;
1:
SetGraphMode(0);
SetBkColor(14);
SetColor(1);
Outtextxy(10,10,'Vychislit ploshad figyri');
Outtextxy(10,20,'metodom Monte-Carlo');
Outtextxy(200,300,'nazhmite na lubuyu clavishu');
readln;
SetGraphMode(0);
clrscr;
SetBkColor(14);
SetColor(0);
outtext('Vvedite kol-vo tochek');
writeln;
readln(n);
i:=0;
Initgraph(i,i,'i:\');
xm:=getmaxx;
ym:=getmaxy;
kx:=xm-2*boundx;
ky:=ym+1-2*boundy;
hx:=(b-a)/(kx-1);
hy:= 30;
setcolor(2);
x0:=-xm div 2 +boundx;
y0:=-ym div 2-boundy;
setcolor(2);
setviewport(getmaxx div 2,getmaxy div 2,getmaxx,getmaxy,clipoff);
line(-xm div 2,0,xm div 2,0);
line(0,ym div 2 ,0,-ym div 2);
setcolor(4);
rectangle(-300,200,300,-200);
setcolor(3);
line(-150,150,150,150);
line(-150,150,-200,0);
line(-200,0,0,-150);
line(0,-150,200,0);
line(200,0,150,150);
For i:= 1 to n do begin
x:=round(random*600-300);
y:=round(random*400-200);
If (y>150) and (y>-3*x-300) and (y<-3*x/40-15) and
(y<3*x/4-15) and(y>-3*x+600)then
begin k:=k+1;
putpixel(x,y,13);
end
else putpixel(x,y,6);
end;
str(k,s);
p:=k/n*600*600;
m:=20800;
str(m,m1);
str(p:10:1,p1);
outtextxy(-100,90,'Kolichesvo popavshix tochek='+s+'');
outtextxy(-100,100,'Plochad metodom Monte-Karlo='+p1+'');
readln;
clrscr;
goto 5;
{End Zadacha1}
SetGraphMode(1);
SetColor(15);
SetBkColor(2);
outtextxy(100,300,'Ќ*¦¬ЁвҐ ** «оЎго Є«*ўЁиг');
readln;
clrscr;
2: {Zadacha 2 nachalo)}
closegraph;
writeln('Vivod Spirali Arhimeda: ');
i:=0;
gd:=ega;
gm:=egahi;
initgraph(gd,gm,'i:\');
directvideo:=false;
x0:=getmaxx div 2;
y0:=getmaxy div 2;
a:=12*pi;
moveto(round(x0+3*a*cos(a)),round(y0-3*a*sin(a)));
while a>0 do
begin
x:=round(x0+3*a*cos(a));
y:=round(y0-3*a*sin(a));
a:=a-0.0001;
lineto(x,y);
end;
readln;
3:
closeGraph;
end.