|
|||
Додаток АДодаток А Program GRAPHICS; Uses Graph,dos, CRT; type zet=array[1..102]of real; Var a,b,c,d: zet; H:array[1..408] of real; F:file of real; x,y,o:real; l:integer;
DM:integer; s,s1,s2,s3,s4,z1,z2,z3,z4:string;
Procedure POCHATOK; CONST K=6; n=6; VAR GD,GM:INTEGER; PROCEDURE SNOW(X0,Y0,R,N:INTEGER); CONST T=2*PI/K; VAR I,X,Y:INTEGER; BEGIN FOR I:=1 TO K DO BEGIN X:=X0+ROUND(R*COS(I*T)); Y:=Y0-ROUND(R*SIN(I*T)); DELAY(10); SETCOLOR(15); LINE(X0,Y0,X,Y); IF N>1 THEN SNOW(X,Y,R DIV 3,N-1) END END; BEGIN setbkcolor(1); SNOW(320,240,ROUND(160/(1-1/(EXP(N*LN(3))))),N); SETTEXTSTYLE(7,0,6); setcolor(10); delay(10000); outtextxy(200,160,'C'); delay(10000); outtextxy(230,160,'o'); delay(10000); outtextxy(260,160,'u'); delay(10000); outtextxy(290,160,'r'); delay(10000); outtextxy(320,160,'s'); delay(10000); outtextxy(350,160,'e'); delay(10000); outtextxy(400,160,'o');
delay(10000);outtextxy(430,160,'f'); delay(10000); outtextXY(50,260,'Yuriy Zaharchenko'); Repeat SETTEXTSTYLE(1,0,1); SetColor(red); OutTextXY(250,450,'Press Enter..'); Delay(9000); SetColor(black); OutTextXY(250,450,'Press Enter..'); Delay(9000); Until KeyPressed; READLN; END;
Procedure COORDMAS(var w:zet); Var i:byte; c:char; BEGIN repeat c:=readkey; case c of 'a': begin l:=1; s:='y:=0.5*x*x-3'; while l<=102 do BEGIN X:=0.1*(L-51); Y:=0.5*x*x-3; w[L]:=X; w[L+1]:=Y; l:=l+2; END; end;
'b': begin l:=1; s:='y:=x*(x*x-4)'; while l<=102 do BEGIN X:=0.05*(L-51); Y:=x*(x*x-4); w[L]:=X; w[L+1]:=Y; l:=l+2; END; end;
'c': begin l:=1; s:='y:=2*cos(x-1)+abs(x)'; while l<=102 do BEGIN X:=0.1*(L-51); Y:=2*cos(x-1)+abs(x); w[L]:=X; w[L+1]:=Y; l:=l+2; END; end;
'd': begin l:=1; s:='y:=0.5*x-5'; while l<=102 do BEGIN X:=0.3*(L-51); Y:=0.5*x-5; w[L]:=X; w[L+1]:=Y; l:=l+2; END; end;
'e': begin l:=1; s:='y:=2*sin(x)'; while l<=102 do BEGIN X:=0.1*(L-51); Y:=2*sin(x); w[L]:=X; w[L+1]:=Y; l:=l+2; END; end;
'f': begin l:=1; s:='y:=(3*x+3)/(0.2*x-3)'; while l<=102 do BEGIN X:=0.1*(L-51); Y:=(3*x+3)/(0.2*x-3); w[L]:=X; w[L+1]:=Y; l:=l+2; END; end; end; if (c<>'a') and (c<>'b') and (c<>'c') and (c<>'d') and (c<>'e') and (c<>'f') then begin l:=1; s:='Error: INVALID USER'; while l<=102 do begin X:=0.35*(L-51); Y:=X;w[L]:=X; w[L+1]:=Y; l:=l+2; end; end; until c<>' '; end;
Procedure MENU; Var i:byte; begin SETCOLOR(GREEN); SETTEXTSTYLE(7,0,1); OUTTEXTXY(230,230,' y = 0.5*X*X - 3'); OUTTEXTXY(230,250,' y = X*(X*X - 4)'); OUTTEXTXY(230,270,' y = 2*cos(X - 1) + |X|'); OUTTEXTXY(230,290,' y = 0.5*X - 5'); OUTTEXTXY(230,310,' y = 2*sin(x)'); OUTTEXTXY(230,330,' y = (3*x+3)/(0.2*x-3);');
SETTEXTSTYLE(0,0,0); i:=1; repeat delay(10000); SETCOLOR(8); OUTTEXTXY(200,240,'a).'); delay(10000); SETCOLOR(red);OUTTEXTXY(200,240,'a).'); i:=i+1 until i=5; i:=1; repeat delay(10000); SETCOLOR(8); OUTTEXTXY(200,260,'b).'); delay(10000); SETCOLOR(red); OUTTEXTXY(200,260,'b).'); i:=i+1 until i=5; i:=1; repeat delay(10000); SETCOLOR(8); OUTTEXTXY(200,280,'c).'); delay(10000); SETCOLOR(red); OUTTEXTXY(200,280,'c).'); i:=i+1 until i=5; i:=1; repeat delay(10000); setcolor(8); OUTTEXTXY(200,300,'d).'); delay(10000); setcolor(red); OUTTEXTXY(200,300,'d).'); i:=i+1 until i=5; i:=1; repeat delay(10000); setcolor(8); OUTTEXTXY(200,320,'e).'); delay(10000); setcolor(red); OUTTEXTXY(200,320,'e).'); i:=i+1 until i=5; i:=1; repeat delay(10000); setcolor(8); OUTTEXTXY(200,340,'f).'); delay(10000); setcolor(red); OUTTEXTXY(200,340,'f).'); i:=i+1 until i=5;
SETCOLOR(BLUE); SETTEXTSTYLE(7,0,1); OUTTEXTXY(70,410,'Press a, b, c, d, e or f to choose the graph '); end;
Procedure Menu1(var z:string; color, znak:word); begin
SETBKCOLOR(color); RECTANGLE(160,120,480,360); SETFILLSTYLE(1,8); BAR(160,120,480,360); SETCOLOR(znak); SETTEXTSTYLE(0,0,0); OUTTEXTXY(180,140,'What graph of function want You see'); OUTTEXTXY(180,180,z); end;
Procedure MAS; Var i:integer; begin for i:=1 to 102 do H[i]:=a[i]; for i:=103 to 204 do H[i]:=b[i-102]; for i:=205 to 306 do H[i]:=c[i-204]; for i:=307 to 408 do H[i]:=d[i-306]; end;
Procedure COORDFILE; Var l:integer; begin ASSIGN(F,'a:\COORD.DAT'); REWRITE(F); FOR L:=1 TO 408 DO WRITE(F,H[L]); end;
Procedure NAZVA; begin SETTEXTSTYLE(0,0,0); SETCOLOR(BLUE); OUTTEXTXY(30,220,S1); OUTTEXTXY(350,220,S2); OUTTEXTXY(30,460,S3);
OUTTEXTXY(350,460,S4); END;
Procedure LINES; Var i:integer; begin SETCOLOR(15); SETLINESTYLE(0,0,0); LINE(160,240,160,0); LINE(0,120,320,120); FOR I:=1 TO 32 DO LINE(I+(I*9),119,I+(I*9),121); FOR I:=1 TO 24 DO LINE(161,I+(I*9),159,I+(I*9)); LINE(480,240,480,0); LINE(320,120,640,120); FOR I:=1 TO 32 DO LINE( I+(I*9)+320,119,I+(I*9)+320,121); FOR I:=1 TO 24 DO LINE(481,I+(I*9),479,I+(I*9)); LINE(160,240,160,480); LINE(0,360,320,360); FOR I:=1 TO 32 DO LINE(I+(I*9),359,I+(I*9),361); FOR I:=1 TO 24 DO LINE(161,I+(I*9)+240,159,I+(I*9)+240); LINE(480,240,480,480); LINE(320,360,640,360); FOR I:=1 TO 32 DO LINE(I+(I*9)+320,359,I+(I*9)+320,361); FOR I:=1 TO 24 DO LINE(481,I+(I*9)+240,479,I+(I*9)+240); SETCOLOR(RED); SETLINESTYLE(0,1,3); LINE(320,0,320,480); LINE(0,240,640,240); end;
Procedure GRAPHS; begin DM:=detect; initgraph(dm,dm,''); if graphresult<>grOk then halt(1); end;
BEGIN GRAPHS; POCHATOK; CLEARDEVICE; z1:='in the high left corner?'; z2:='in the high right corner?'; z3:='in the low left corner?'; z4:='in the low right corner?'; MENU1(z1,5,15); MENU; COORDMAS(a); s1:=s; MENU1(z2,11,11); MENU; COORDMAS(b); s2:=s; MENU1(z3,5,15); MENU; COORDMAS(c); s3:=s; MENU1(z4,14,14); MENU; COORDMAS(d); s4:=s; MAS; COORDFILE; SETBKCOLOR(0); clearviewport;
LINES; NAZVA; assign(f,'coord.dat'); l:=1; RESET(F); while L<=102 do BEGIN
READ(F,o); delay(7000); X:=H[L]; Y:=H[L+1]; PUTPIXEL(ROUND(160+10*X),ROUND(120-10*Y),5); l:=l+2; END; l:=103; while l<=204 do begin read(F,o); delay(7000); x:= H[l]; Y:=H[L+1]; PUTPIXEL(ROUND(480+10*X),ROUND(120-10*Y),GREEN); L:=L+2; END; l:=205; while l<=306 do begin read(F,o); delay(7000); x:= H[l]; Y:=H[L+1]; PUTPIXEL(ROUND(160+10*X),ROUND(360-10*Y),15); L:=L+2; END; l:=307; while l<=408 do begin read(F,o); delay(7000); x:= H[l]; Y:=H[L+1]; PUTPIXEL(ROUND(480+10*X),ROUND(360-10*Y),RED); L:=L+2; END;
READKEY; close(f); END. Додаток Б
|
|||
|