1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
| uses crt,GraphABC;
label poch,m1,m2;
const mas:array[1..4] of string=('1 - Zagolovok',
'2- Zavdanya #1',
'3 - Zavdanya #2',
'4 - Exit');
masp:array[1..5] of string=('2.1 - Umova zavdanya',
'2.2 - Tabyliacia functcii',
'2.3 - Vivedennia tabyliacii na ekran',
'2.4 - Grafik functcii',
'Nazad');
masp1:array[1..4] of string=('3.1 - Umova zavdania',
'3.2 - Vmist faily',
'3.3 - Vivedennia trikutnikiv',
'Nazad');
type toch=record
x,y:integer;
end;
procedure oprGraph;
var gd,gm:integer;
begin
gd:= detect;
initgraph(gd,gm,' ');
end;
procedure zavdanya;
begin
writeln('Student grupy KM-145, LOPATIN VLADISLAV STANISLAVOVICH');
writeln('Kursova robora');
writeln('Stvorenya programnogo kompleksu movamy programuvanya Pascal ta C');
writeln('Individualne zavdanya #6');
end;
procedure umova1;
begin
writeln('Vikonati tabuliaciy parametrichni zadanoii funkcii');
writeln('(Ravlik Paskalya(kardioida)), zapisati ii u fail ta vivesti iogo na ekran.');
writeln('Pobuduvati i vivesty na ekran monitora graphik ciei funkcii:');
writeln('x=a*sqr(cos(t))+b*cos(t)');
writeln('y=cos(t)*sin(t)+b*sin(t)');
writeln('a,b >0; t (0;2*pi)');
readkey;
end;
procedure umova2;
begin
writeln(' U file zadano koordinaty tochok. Kilkist yakih');
writeln('bilsha desati. Vivesti na ekran 10 tochok, u yakih vodstan');
writeln('vid centra ekranu naymensha. Provesti cherez ci tichki lamanu');
writeln('liniyu. Okremim kolorom vidility naykorotshiy ta');
writeln('naydovshiy vidrizki lamanoi');
readkey;
end;
function tabx(a,b,t:real):real;
begin
tabx:=a*sqr(cos(t))+b*cos(t);
end;
function taby(a,b,t:real):real;
begin
taby:=cos(t)*sin(t)+b*sin(t);
end;
procedure vvod(a,b:real; n:integer);
var t,c:real; fil:text;
begin
assign(fil,'tabulyacia.txt');
rewrite(fil);
clrscr;
c:=abs((2*pi)/(n-1));
t:=0;
writeln(fil,'ЙНННННННННННЛННННННННННН»');
writeln(fil,'є x є y є');
writeln(fil,'МНННННННННННКННННННННННН№');
while (t<=2*pi) do
begin
writeln(fil,'є x=',tabx(a,b,t):7:3,'і y=',taby(a,b,t):7:3,'є');
writeln(fil,'єДДДДДДДДДДДЕДДДДДДДДДДДє');
t:=t+c;
end;
writeln(fil,'ИНННННННННННННННННННННННј');
write('Tabulyaciy i zapis u file zaversheno');
readkey;
close(fil);
end;
procedure vivod;
var fil:text; s:string;
begin
clrscr;
assign(fil,'tabulyac.txt');
reset(fil);
while not eof(fil) do
begin
readln(fil,s);
writeln(s);
end;
readkey;
close(fil);
end;
function menu1riv:integer;
var c,h,h1:integer; a1:char;
begin
oprGraph;
h:=1;
h1:=1;
setbkcolor(2);
settextstyle(0,0,0);
setfillstyle(1,14);
for c:=1 to 4 do
begin
bar(0,c*35+105,640,c*35+135);
setcolor(0);
outtextxy(270,c*35+115,mas[c]);
setcolor(red);
setlinestyle(3,2,3);
rectangle(0,h*35+105,640,h*35+135);
end;
setfillstyle(1,8);
bar(0,141,640,170);
setcolor(15);
outtextxy(270,150,mas[1]);
setcolor(red);
setlinestyle(3,2,3);
rectangle(0,h*35+105,640,h*35+135);
repeat
repeat
a1:=readkey;
until a1 in [#72, #80, #13, #27];
case a1 of
#72: h:=h-1;
#80: h:=h+1;
end;
if (h=5) then h:=1; if h=0 then h:=4;
setfillstyle(1,14);
bar(0,h1*35+105,640,h1*35+135);
setcolor(0);
outtextxy(270,h1*35+115,mas[h1]);
setfillstyle(1,8);
bar(0,h*35+105,640,h*35+135);
setcolor(15);
outtextxy(270,h*35+115,mas[h]);
setcolor(red);
setlinestyle(3,2,3);
rectangle(0,h*35+105,640,h*35+135);
h1:=h;
menu1riv:=h;
until (a1=#13);
closegraph;
end;
function menuzav1:integer;
var c,h,h1:integer; a1:char;
begin
oprGraph;
h:=1;
h1:=1;
setbkcolor(2);
settextstyle(0,0,0);
setfillstyle(1,14);
for c:=1 to 5 do
begin
bar(0,c*35+105,640,c*35+135);
setcolor(0);
outtextxy(270,c*35+115,masp[c]);
end;
setfillstyle(1,8);
bar(0,141,640,170);
setcolor(15);
outtextxy(270,150,masp[1]);
setcolor(red);
setlinestyle(3,2,3);
rectangle(0,h*35+105,640,h*35+135);
repeat
repeat
a1:=readkey;
until a1 in [#72, #80, #13, #27];
case a1 of
#72: h:=h-1;
#80: h:=h+1;
end;
if (h=6) then h:=1; if h=0 then h:=5;
setfillstyle(1,14);
bar(0,h1*35+105,640,h1*35+135);
setcolor(0);
outtextxy(270,h1*35+115,masp[h1]);
setfillstyle(1,8);
bar(0,h*35+105,640,h*35+135);
setcolor(0);
outtextxy(270,h*35+115,masp[h]);
setcolor(red);
setlinestyle(3,2,3);
rectangle(0,h*35+105,640,h*35+135);
h1:=h;
menuzav1:=h;
until (a1=#13);
closegraph;
end;
function menuzav2:integer;
var c,h,h1:integer; a1:char;
begin
oprGraph;
h:=1;
h1:=1;
setbkcolor(2);
settextstyle(0,0,0);
setfillstyle(1,14);
for c:=1 to 4 do
begin
bar(0,c*35+105,640,c*35+135);
setcolor(0);
outtextxy(270,c*35+115,masp1[c]);
end;
setfillstyle(1,8);
bar(0,141,640,170);
setcolor(15);
outtextxy(270,150,masp1[1]);
setcolor(red);
setlinestyle(3,2,3);
rectangle(0,h*35+105,640,h*35+135);
repeat
repeat
a1:=readkey;
until a1 in [#72, #80, #13, #27];
case a1 of
#72: h:=h-1;
#80: h:=h+1;
end;
if (h=5) then h:=1; if h=0 then h:=4;
setfillstyle(1,14);
bar(0,h1*35+105,640,h1*35+135);
setcolor(0);
outtextxy(270,h1*35+115,masp1[h1]);
setfillstyle(1,8);
bar(0,h*35+105,640,h*35+135);
setcolor(0);
outtextxy(270,h*35+115,masp1[h]);
setcolor(red);
setlinestyle(3,2,3);
rectangle(0,h*35+105,640,h*35+135);
h1:=h;
menuzav2:=h;
until (a1=#13);
closegraph;
end;
procedure graphik(a,b:real);
var t,y:real; k:integer;
begin
oprGraph;
t:=0;
setbkcolor(15);
setcolor(2);
line(320,0,320,480);
line(0,240,640,240);
k:=0;
while k<=640 do
begin
line(10+k,237,10+k,243);
k:=k+10;
end;
k:=0;
while k<=480 do
begin
line(317,5+k,323,5+k);
k:=k+10;
end;
while (t<2*pi) do
begin
putpixel(round(tabx(a,b,t)*10+320),round(taby(a,b,t)*10+240),1);
t:=t+0.0001;
end;
readln;
closegraph;
end;
procedure vmistft;
var f:text; l:integer; at:toch;
begin
assign(f,'koord.txt');
reset(f);
l:=1;
while not eof(f) do
begin
read(f,at.x,at.y);
writeln('Tochka ',l,': (',at.x,';',at.y,')');
l:=l+1;
end;
readkey;
end;
procedure tochki;
var at:toch; vid,min,mint,maxt:real;
l,k,t,i,j,x,y:integer;
f:text;
vids:array[1..99] of real;
vidst:array[1..99] of real;
rezul:array[1..10] of real;
koordx:array[1..99] of integer;
koordy:array[1..99] of integer;
koordx1:array[1..10] of integer;
koordy1:array[1..10] of integer;
begin
k:=1;
assign(f,'koord.txt');
reset(f);
while not eof(f) do
begin
read(f,at.x,at.y);
vid:=sqrt(sqr(at.x)+sqr(at.y));
vids[k]:=vid;
koordx[k]:=at.x; koordy[k]:=at.y;
k:=k+1;
end;
l:=1;
while l<k do
begin
vidst[l]:=vids[l];
l:=l+1;
end;
t:=1;
while t<=10 do
begin
l:=1;
min:=9999;
while l<k do
begin
if min>=vidst[l] then min:=vidst[l];
l:=l+1;
end;
l:=1;
while l<k do
begin
if vidst[l]=min then vidst[l]:=9999;
l:=l+1;
end;
rezul[t]:=min;
t:=t+1;
end;
l:=1;
oprGraph;
j:=1;
setcolor(2);
line(320,0,320,480);
line(0,240,640,240);
while j<=10 do
begin
l:=1;
while l<k do
begin
if (vids[l]=rezul[j]) then begin koordx1[j]:=koordx[j];
koordy1[j]:=koordy[j];
circle(koordx[j]*20+320,abs(koordy[j]*20-240),2);
end;
l:=l+1;
end;
j:=j+1;
end;
j:=0;
while j<=640 do
begin
line(317,j,323,j);
line(j,237,j,243);
j:=j+20;
end;
j:=1;
while j<=10 do
begin
if j=10 then line(koordx1[j]*20+320,abs(koordy1[j]*20-240),koordx1[1]*20+320,abs(koordy1[1]*20-240)) else
line(koordx1[j]*20+320,abs(koordy1[j]*20-240),koordx1[j+1]*20+320,abs(koordy1[j+1]*20-240));
j:=j+1;
end;
readkey;
close(f);
closegraph;
end;
var a,b:real; a1,n:integer;
begin
clrscr;
poch: a1:=menu1riv;
case a1 of
1: begin zavdanya; readkey; goto poch; end;
2: begin m1: case menuzav1 of
1: begin umova1; goto m1; end;
2: begin clrscr;
a:=-1;
b:=-1;
repeat
if a<0 then begin write('Vvedite a='); readln(a); end;
if b<0 then begin write('Vvedite b='); readln(b); end;
until ((a>0) and (b>0));
write('Vvedite kilkist krokiv: '); read(n);
vvod(a,b,n);
goto m1; end;
3: begin vivod; goto m1; end;
4: begin
clrscr;
a:=-1;
b:=-1;
repeat
if a<0 then begin write('Vvedite a='); readln(a); end;
if b<0 then begin write('Vvedite b='); readln(b); end;
until ((a>0) and (b>0));
graphik(a,b);
goto m1 end;
5: goto poch;
end;
end;
3: begin m2: case menuzav2 of
1: begin umova2; goto m2; end;
2: begin vmistft; goto m2; end;
3: begin tochki; goto m2; end;
4: goto poch;
end;
end;
4: exit;
end;
end. |