Repository navigation
Expand file tree
/
Copy pathLibrary.PAS
More file actions
994 lines (972 loc) · 42.1 KB
/
Copy pathLibrary.PAS
File metadata and controls
994 lines (972 loc) · 42.1 KB
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
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
Uses GRAPH, CRT;
Type Cucak = record
Anun : string[18];
Azganun : string[19];
GrqiAnun : Array [1..100] of string[19];
GrqiHexinak : Array [1..100] of string[19];
Qanak : integer;
End;
Var dr, md, But, MaxN : integer;
elq : boolean;
c : char;
Bajanord : Cucak;
Const DOWN=#208; UP=#200; LEFT=#203; RIGHT=#205; ESC=#27; NULL=#0; ENTER=#13; SPACE=#32; BackSpace=#8;
Mode : Array [1..4] of string[9] = ('Problem', 'Input', 'Solution', 'Exit');
CucakLength=18+19+20*19+20*19+2;
Function GetKey : Char;
Var c : char;
Begin {GetKey}
c:=ReadKey;
Repeat
if c=NULL then
Begin c:=ReadKey;
if Ord(c)>127 then c:=NULL
else GetKey:=Chr(Ord(C)+128);
End
else GetKey:=c;
Until c<>NULL;
End; {GetKey}
Procedure Menu;
Begin
SetFillStyle(1, LightBlue); SetColor(White); SetTextStyle(0, 0, 3);
Bar(0, 0, GetMaxX, GetMaxY);
OutTextXY(236, 112, Mode[1]);
OutTextXY(260, 172, Mode[2]);
OutTextXY(224, 232, Mode[3]);
OutTextXY(272, 292, Mode[4]);
SetColor(Blue); SetLineStyle(0, 0, 3);
Line(224, 140, 416, 140);
But:=1;
End;
Procedure Problem;
Begin
SetFillStyle(1, DarkGray);
Bar(0, 0, GetMaxX, GetMaxY);
SetTextStyle(1, 0, 2); SetColor(LightGray);
OutTextXY(15, 80+10, 'Stexcel teqstayin fayl, vortex hajordabar petq e grancel');
OutTextXY(15, 80+40, 'bajanordneri azganuny, anuny yev bajanordagrvac grqeri');
OutTextXY(15, 80+70, 'vernagrery hexinaknerov.');
OutTextXY(15, 80+100, 'Cragrum petq e naxatesel mijocner, voronq kapahoven');
OutTextXY(15, 80+130, 'fayli lracman hnaravorutyunnery` voch miayn nor');
OutTextXY(15, 80+160, 'bajanordneri yev nranc bajanordagrman cankov, ayl');
OutTextXY(15, 80+190, 'nayev naxkinum grancvac cankeri lracumov.');
OutTextXY(15, 80+220, 'Arandzin rejimov naxatesel fayli parunakutyan');
OutTextXY(15, 80+250, 'artapatkerumy axyusaki tesqov grafikakan ekrani vra.');
GetKey;
End;
Procedure InDat;
Var i, n, j : integer;
f : file of Cucak;
Bajanord : Cucak;
Begin
RestoreCrtMode;
Assign(f, 'input.txt'); Rewrite(f);
Write('Mutqagreq skzbnakan bajanordneri qanaky : ');
Readln(n); MaxN:=n;
Writeln('Mutqagreq ', n, ' bajanordi tvyalner.');
Writeln;
for i:=1 to n do
With Bajanord do
Begin
Writeln('-----', i, '-----');
Write('Bajanordi Anun : ');Readln(Anun);
Write('Bajanordi Azganun : ');Readln(Azganun);
Repeat
Write('Grqeri qanak : '); Readln(Qanak);
Until Qanak<100;
for j:=1 to Qanak do
Begin
Write('Girq_', j, ' Anun : ');Readln(GrqiAnun[j]);
Write('Girq_', j, ' Hexinak : ');Readln(GrqiHexinak[j]);
End;
Write(f, Bajanord);
End;
Close(f);
Writeln;
Writeln('Mutqagrumn avartvac e sexmeq kamayakan stexn durs galu hamar.');
GetKey;
SetGraphMode(GetGraphMode);
End;
Procedure Solution;
Var f : file of Cucak;
ej, min, i, Button : integer;
Procedure DrawLine(y : integer);
Begin {DrawLine}
SetFillStyle(1, White);
Bar(1, y, 25, y+10);
Bar(27, y, 171, y+10);
Bar(173, y, 327, y+10);
Bar(329, y, 483, y+10);
Bar(485, y, 638, y+10);
End; {DrawLine}
Procedure FillLine(y, i : integer; Baj : Cucak);
Var s : string;
Begin {FillLine}
SetTextStyle(0, 0, 1); SetColor(Black);
str(i, s); SetColor(Red);
OutTextXY(1+(25-Length(s)*8)div 2, y+2, s);
SetColor(Black);
With Baj do
Begin
OutTextXY(29, y+2, Anun);
OutTextXY(175, y+2, Azganun);
OutTextXY(331, y+2, GrqiAnun[1]);
OutTextXY(487, y+2, GrqiHexinak[1]);
End;
End; {FillLine}
Procedure GnalEj(x : integer);
Var i, j, min : integer;
f : file of Cucak;
Begin {GnalEj}
Assign(f, 'input.txt'); Reset(f);
if (x>0) and (x<=((MaxN-1) div 37)+1) then
Begin
SetFillStyle(1, LightBlue);
Bar(0, 36, GetMaxX, GetMaxY);
ej:=x;
if ej*37<MaxN then min:=ej*37 else min:=MaxN;
seek(f, (ej-1)*37);
for i:=(ej-1)*37+1 to min do
Begin
if eof(f) then
With Bajanord do
Begin
Anun:=''; Azganun:=''; Qanak:=0;
for j:=1 to 100 do
Begin
GrqiAnun[j]:='';
GrqiHexinak[j]:='';
End;
End
else Read(f, Bajanord);
DrawLine(24+(i-(ej-1)*37)*12);
FillLine(24+(i-(ej-1)*37)*12, i, Bajanord);
End;
End;
Close(f);
End; {GnalEj}
Procedure Nayel;
Var i, Button, y, min, GrqEj, j : integer;
s : string[5];
f : file of Cucak;
NorEj : boolean;
Begin {Nayel}
if MaxN>0 then Begin
Assign(f, 'input.txt'); Reset(f);
i:=(ej-1)*37+1;
Repeat
SetFillStyle(1, LightGray); SetColor(Red); str(i, s); SetTextStyle(0, 0, 1);
Bar(1, 24+(i-(ej-1)*37)*12, 25, 24+(i-(ej-1)*37)*12+10);
OutTextXY(1+(25-Length(s)*8)div 2, 24+(i-(ej-1)*37)*12+2, s);
C:=GetKey; if ej*37<MaxN then min:=ej*37 else min:=MaxN;
if (C=DOWN) and (i<min) then
Begin
SetFillStyle(1, White); str(i, s); SetColor(Red);
Bar(1, 24+(i-(ej-1)*37)*12, 25, 24+(i-(ej-1)*37)*12+10);
OutTextXY(1+(25-Length(s)*8)div 2, 24+(i-(ej-1)*37)*12+2, s);
i:=i+1;
SetFillStyle(1, LightGray);
Bar(1, 24+(i-(ej-1)*37)*12, 25, 24+(i-(ej-1)*37)*12+10);
str(i, s);
OutTextXY(1+(25-Length(s)*8)div 2, 24+(i-(ej-1)*37)*12+2, s);
End
else if (C=UP) and (i>(ej-1)*37+1) then
Begin
SetFillStyle(1, White); str(i, s); SetColor(Red);
Bar(1, 24+(i-(ej-1)*37)*12, 25, 24+(i-(ej-1)*37)*12+10);
OutTextXY(1+(25-Length(s)*8)div 2, 24+(i-(ej-1)*37)*12+2, s);
i:=i-1;
SetFillStyle(1, LightGray);
Bar(1, 24+(i-(ej-1)*37)*12, 25, 24+(i-(ej-1)*37)*12+10);
str(i, s);
OutTextXY(1+(25-Length(s)*8)div 2, 24+(i-(ej-1)*37)*12+2, s);
End
else if C=ENTER then
Begin
SetFillStyle(1, LightBlue);
Bar(0, 36, GetMaxX, GetMaxY);
DrawLine(36); seek(f, i-1); Read(f, Bajanord);
FillLine(36, i, Bajanord);
if Bajanord.Qanak<=37 then min:=Bajanord.Qanak else min:=37;
for j:=2 to min do
Begin
Bar(329, 24+j*12, 483, 24+j*12+10);
Bar(485, 24+j*12, 638, 24+j*12+10);
OutTextXY(331, 24+j*12+2, Bajanord.GrqiAnun[j]);
OutTextXY(487, 24+j*12+2, Bajanord.GrqiHexinak[j]);
End;
SetColor(Brown); SetLineStyle(0, 0, 1);
Rectangle(240+(-1)*30, 1, 260+(-1)*30, 21);
SetColor(Yellow);
Rectangle(240+3*30, 1, 260+3*30, 21);
Button:=1; GrqEj:=1;
Repeat
C:=GetKey;
if (C=RIGHT) and (Button=1) then
Begin
SetColor(Brown); SetLineStyle(0, 0, 1);
Rectangle(240+3*30, 1, 260+3*30, 21);
Button:=2;
SetColor(Yellow);
Rectangle(240+4*30, 1, 260+4*30, 21);
End
else if (C=LEFT) and (Button=2) then
Begin
SetColor(Brown); SetLineStyle(0, 0, 1);
Rectangle(240+4*30, 1, 260+4*30, 21);
Button:=1;
SetColor(Yellow);
Rectangle(240+3*30, 1, 260+3*30, 21);
End
else if C=ENTER then
Begin
NorEj:=False;
if (Button=1) and (GrqEj>1) then
Begin GrqEj:=GrqEj-1; NorEj:=True; End
else if (Button=2) and (GrqEj<(Bajanord.Qanak-1) div 37 + 1) then
Begin GrqEj:=GrqEj+1; NorEj:=True; End;
if NorEj then
Begin
SetFillStyle(1, LightBlue);
Bar(329, 36, GetMaxX, GetMaxY);
j:=(GrqEj-1)*37+1;
SetFillStyle(1, White); SetColor(Black);
if Bajanord.Qanak<GrqEj*37 then min:=Bajanord.Qanak else min:=GrqEj*37;
for j:=(GrqEj-1)*37+1 to min do
Begin
Bar(329, 24+(j-(GrqEj-1)*37)*12, 483, 24+(j-(GrqEj-1)*37)*12+10);
Bar(485, 24+(j-(GrqEj-1)*37)*12, 638, 24+(j-(GrqEj-1)*37)*12+10);
OutTextXY(331, 24+(j-(GrqEj-1)*37)*12+2, Bajanord.GrqiAnun[j]);
OutTextXY(487, 24+(j-(GrqEj-1)*37)*12+2, Bajanord.GrqiHexinak[j]);
End;
End;
End;
Until C=ESC; C:=NULL;
GnalEj(ej);
SetColor(Brown);
Rectangle(240+(Button+2)*30, 1, 260+(Button+2)*30, 21);
SetColor(Yellow);
Rectangle(240+(-1)*30, 1, 260+(-1)*30, 21);
End;
Until C=ESC; C:=NULL;
SetFillStyle(1, White); str(i, s); SetColor(Red);
Bar(1, 24+(i-(ej-1)*37)*12, 25, 24+(i-(ej-1)*37)*12+10);
OutTextXY(1+(25-Length(s)*8)div 2, 24+(i-(ej-1)*37)*12+2, s);
Close(f);
End; {End of 'if MaxN>0'}
End; {Nayel}
Procedure Popoxel;
Var i, Button, y, min, GrqEj, j, GirqI : integer;
s : string[20];
f, g : file of Cucak;
Baj : Cucak;
NorEj, Poxvec : boolean;
Begin {Popoxel}
if MaxN>0 then Begin
Assign(f, 'input.txt'); Reset(f);
Assign(g, 'temp.txt');
i:=(ej-1)*37+1;
Repeat
SetFillStyle(1, LightGray); SetColor(Red); str(i, s); SetTextStyle(0, 0, 1);
Bar(1, 24+(i-(ej-1)*37)*12, 25, 24+(i-(ej-1)*37)*12+10);
OutTextXY(1+(25-Length(s)*8)div 2, 24+(i-(ej-1)*37)*12+2, s);
C:=GetKey; if ej*37<MaxN then min:=ej*37 else min:=MaxN;
if (C=DOWN) and (i<min) then
Begin
SetFillStyle(1, White); str(i, s); SetColor(Red);
Bar(1, 24+(i-(ej-1)*37)*12, 25, 24+(i-(ej-1)*37)*12+10);
OutTextXY(1+(25-Length(s)*8)div 2, 24+(i-(ej-1)*37)*12+2, s);
i:=i+1;
SetFillStyle(1, LightGray);
Bar(1, 24+(i-(ej-1)*37)*12, 25, 24+(i-(ej-1)*37)*12+10);
str(i, s);
OutTextXY(1+(25-Length(s)*8)div 2, 24+(i-(ej-1)*37)*12+2, s);
End
else if (C=UP) and (i>(ej-1)*37+1) then
Begin
SetFillStyle(1, White); str(i, s); SetColor(Red);
Bar(1, 24+(i-(ej-1)*37)*12, 25, 24+(i-(ej-1)*37)*12+10);
OutTextXY(1+(25-Length(s)*8)div 2, 24+(i-(ej-1)*37)*12+2, s);
i:=i-1;
SetFillStyle(1, LightGray);
Bar(1, 24+(i-(ej-1)*37)*12, 25, 24+(i-(ej-1)*37)*12+10);
str(i, s);
OutTextXY(1+(25-Length(s)*8)div 2, 24+(i-(ej-1)*37)*12+2, s);
End
else if C=ENTER then
Begin
SetFillStyle(1, LightBlue);
Bar(0, 36, GetMaxX, GetMaxY);
DrawLine(36); seek(f, i-1); Read(f, Bajanord);
SetFillStyle(1, LightGray);
Bar(329, 36, 483, 36+10);
FillLine(36, i, Bajanord);
SetFillStyle(1, White); SetCOlor(Black);
if Bajanord.Qanak<=37 then min:=Bajanord.Qanak else min:=37;
for j:=1 to min do
Begin
Bar(329, 24+j*12, 483, 24+j*12+10);
Bar(485, 24+j*12, 638, 24+j*12+10);
OutTextXY(331, 24+j*12+2, Bajanord.GrqiAnun[j]);
OutTextXY(487, 24+j*12+2, Bajanord.GrqiHexinak[j]);
End;
{}
Poxvec:=false;
SetFillStyle(1, LightGray); SetColor(Black); s:=Bajanord.Anun;
Bar(27, 36, 171, 36+10);
OutTextXY(29, 38, s);
SetColor(Black);
Repeat
C:=GetKey;
if (ord(C)>=65) and (ord(C)<=122) and (Length(s)<18) then
Begin
s:=s+C;
OutTextXY(29, 38, s);
End
else if (C=BackSpace) and (s<>'') then
Begin
SetColor(LightGray);
OutTextXY(29, 38, s);
SetColor(Black);
Delete(s, Length(s), 1);
OutTextXY(29, 38, s);
End;
Until (C=ENTER) and (s<>'');
SetFillStyle(1, White); SetColor(Black);
Bar(27, 36, 171, 36+10);
OutTextXY(29, 38, s);
if Bajanord.Anun<>s then Poxvec:=true;
Bajanord.Anun:=s;
SetFillStyle(1, LightGray);
Bar(173, 36, 327, 36+10);
s:=Bajanord.Azganun;
OutTextXY(175, 38, s);
Repeat
C:=GetKey;
if (ord(C)>=65) and (ord(C)<=122) and (Length(s)<18) then
Begin
s:=s+C;
OutTextXY(175, 38, s);
End
else if (C=BackSpace) and (s<>'') then
Begin
SetColor(LightGray);
OutTextXY(175, 38, s);
SetColor(Black);
Delete(s, Length(s), 1);
OutTextXY(175, 38, s);
End;
Until (C=ENTER) and (s<>'');
SetFillStyle(1, White); SetColor(Black);
Bar(173, 36, 327, 36+10);
OutTextXY(175, 38, s);
if Bajanord.Azganun<>s then Poxvec:=true;
Bajanord.Azganun:=s;
{}
if Poxvec then
Begin
Reset(f); Rewrite(g);
j:=0;
while Not Eof(f) do
Begin
j:=j+1;
Read(f, Baj);
if i<>j then
Write(g, Baj)
else
Write(g, Bajanord);
End;
Close(f); Close(g);
Reset(g); Rewrite(f);
while Not Eof(g) do
Begin
Read(g, Baj);
Write(f, Baj);
End;
Close(f); Close(g); Reset(f);
End;
SetFillStyle(1, LightGray);
Bar(329, 36, 483, 36+10);
FillLine(36, i, Bajanord);
SetFillStyle(1, White); SetColor(Black);
Button:=1; GrqEj:=1; GirqI:=1;
Repeat
C:=GetKey;
if (C=RIGHT) and (Button<5) then
Begin
SetColor(Brown); SetLineStyle(0, 0, 1);
Rectangle(240+(Button-1)*30, 1, 260+(Button-1)*30, 21);
Button:=Button+1;
SetColor(Yellow);
Rectangle(240+(Button-1)*30, 1, 260+(Button-1)*30, 21);
End
else if (C=LEFT) and (Button>1) then
Begin
SetColor(Brown); SetLineStyle(0, 0, 1);
Rectangle(240+(Button-1)*30, 1, 260+(Button-1)*30, 21);
Button:=Button-1;
SetColor(Yellow);
Rectangle(240+(Button-1)*30, 1, 260+(Button-1)*30, 21);
End
else if (C=DOWN) and (GirqI<min) then
Begin
SetFillStyle(1, White); SetColor(Black);
Bar(329, 24+(GirqI-(GrqEj-1)*37)*12, 483, 24+(GirqI-(GrqEj-1)*37)*12+10);
OutTextXY(331, 24+(GirqI-(GrqEj-1)*37)*12+2, Bajanord.GrqiAnun[GirqI]);
GirqI:=GirqI+1;
SetFillStyle(1, LightGray);
Bar(329, 24+(GirqI-(GrqEj-1)*37)*12, 483, 24+(GirqI-(GrqEj-1)*37)*12+10);
OutTextXY(331, 24+(GirqI-(GrqEj-1)*37)*12+2, Bajanord.GrqiAnun[GirqI]);
End
else if (C=UP) and (GirqI>(GrqEj-1)*37+1) then
Begin
SetFillStyle(1, White); SetColor(Black);
Bar(329, 24+(GirqI-(GrqEj-1)*37)*12, 483, 24+(GirqI-(GrqEj-1)*37)*12+10);
OutTextXY(331, 24+(GirqI-(GrqEj-1)*37)*12+2, Bajanord.GrqiAnun[GirqI]);
GirqI:=GirqI-1;
SetFillStyle(1, LightGray);
Bar(329, 24+(GirqI-(GrqEj-1)*37)*12, 483, 24+(GirqI-(GrqEj-1)*37)*12+10);
OutTextXY(331, 24+(GirqI-(GrqEj-1)*37)*12+2, Bajanord.GrqiAnun[GirqI]);
End
else if C=ENTER then
Begin
NorEj:=False;
if (Button=4) and (GrqEj>1) then
Begin GrqEj:=GrqEj-1; NorEj:=True; End
else if (Button=5) and (GrqEj<(Bajanord.Qanak-1) div 37 + 1) then
Begin GrqEj:=GrqEj+1; NorEj:=True; End
else if (Button=3) and (Bajanord.Qanak<100) then
Begin GrqEj:=(Bajanord.Qanak-1) div 37 + 1; NorEj:=True; End;
if NorEj then
Begin
GirqI:=(GrqEj-1)*37+1;
SetFillStyle(1, LightBlue);
Bar(329, 36, GetMaxX, GetMaxY);
SetFillStyle(1, White); SetColor(Black);
if Bajanord.Qanak<GrqEj*37 then min:=Bajanord.Qanak else min:=GrqEj*37;
for j:=(GrqEj-1)*37+1 to min do
Begin
Bar(329, 24+(j-(GrqEj-1)*37)*12, 483, 24+(j-(GrqEj-1)*37)*12+10);
Bar(485, 24+(j-(GrqEj-1)*37)*12, 638, 24+(j-(GrqEj-1)*37)*12+10);
OutTextXY(331, 24+(j-(GrqEj-1)*37)*12+2, Bajanord.GrqiAnun[j]);
OutTextXY(487, 24+(j-(GrqEj-1)*37)*12+2, Bajanord.GrqiHexinak[j]);
End;
SetFillStyle(1, LightGray); SetColor(Black);
Bar(329, 24+(GirqI-(GrqEj-1)*37)*12, 483, 24+(GirqI-(GrqEj-1)*37)*12+10);
OutTextXY(331, 24+(GirqI-(GrqEj-1)*37)*12+2, Bajanord.GrqiAnun[GirqI]);
End
else if Button=1 then
Begin
SetFillStyle(1, LightGray); SetColor(Black); s:=Bajanord.GrqiAnun[GirqI];
Bar(329, 24+(GirqI-(GrqEj-1)*37)*12, 483, 24+(GirqI-(GrqEj-1)*37)*12+10);
OutTextXY(331, 24+(GirqI-(GrqEj-1)*37)*12+2, s);
SetColor(Black);
Repeat
C:=GetKey;
if (ord(C)>=65) and (ord(C)<=122) and (Length(s)<18) then
Begin
s:=s+C;
OutTextXY(331, 24+(GirqI-(GrqEj-1)*37)*12+2, s);
End
else if (C=BackSpace) and (s<>'') then
Begin
SetColor(LightGray);
OutTextXY(331, 24+(GirqI-(GrqEj-1)*37)*12+2, s);
SetColor(Black);
Delete(s, Length(s), 1);
OutTextXY(331, 24+(GirqI-(GrqEj-1)*37)*12+2, s);
End;
Until (C=ENTER) and (s<>'');
SetFillStyle(1, White); SetColor(Black);
Bar(329, 24+(GirqI-(GrqEj-1)*37)*12, 483, 24+(GirqI-(GrqEj-1)*37)*12+10);
OutTextXY(331, 24+(GirqI-(GrqEj-1)*37)*12+2, s);
Bajanord.GrqiAnun[GirqI]:=s;
SetFillStyle(1, LightGray);
Bar(485, 24+(GirqI-(GrqEj-1)*37)*12, 638, 24+(GirqI-(GrqEj-1)*37)*12+10);
s:=Bajanord.GrqiHexinak[GirqI];
OutTextXY(487, 24+(GirqI-(GrqEj-1)*37)*12+2, s);
Repeat
C:=GetKey;
if (ord(C)>=65) and (ord(C)<=122) and (Length(s)<18) then
Begin
s:=s+C;
OutTextXY(487, 24+(GirqI-(GrqEj-1)*37)*12+2, s);
End
else if (C=BackSpace) and (s<>'') then
Begin
SetColor(LightGray);
OutTextXY(487, 24+(GirqI-(GrqEj-1)*37)*12+2, s);
SetColor(Black);
Delete(s, Length(s), 1);
OutTextXY(487, 24+(GirqI-(GrqEj-1)*37)*12+2, s);
End;
Until (C=ENTER) and (s<>'');
SetFillStyle(1, White); SetColor(Black);
Bar(485, 24+(GirqI-(GrqEj-1)*37)*12, 638, 24+(GirqI-(GrqEj-1)*37)*12+10);
OutTextXY(487, 24+(GirqI-(GrqEj-1)*37)*12+2, s);
Bajanord.GrqiHexinak[GirqI]:=s; s:='';
End
else if Button=2 then
Begin
if Bajanord.Qanak>1 then
With Bajanord do
Begin
for j:=GirqI to Bajanord.Qanak-1 do
Begin
GrqiAnun[j]:=GrqiAnun[j+1];
GrqiHexinak[j]:=GrqiHexinak[j+1];
End;
SetFillStyle(1, LightBlue);
Bar(329, 24+min*12, 483, 24+min*12+10);
Bar(485, 24+min*12, 638, 24+min*12+10);
SetFillStyle(1, White);
Qanak:=Qanak-1;
if GirqI<>Qanak+1 then
Begin
SetColor(Black);
if GrqEj*37<Qanak then min:=GrqEj*37 else min:=Qanak;
for j:=GirqI to min do
Begin
Bar(329, 24+j*12, 483, 24+j*12+10);
Bar(485, 24+j*12, 638, 24+j*12+10);
OutTextXY(331, 24+j*12+2, GrqiAnun[j]);
OutTextXY(487, 24+j*12+2, GrqiHexinak[j]);
End;
End
else GirqI:=GirqI-1;
if Qanak<GrqEj*37 then min:=Qanak else min:=GrqEj;
SetFillStyle(1, LightGray); SetColor(Black);
Bar(329, 24+(GirqI-(GrqEj-1)*37)*12, 483, 24+(GirqI-(GrqEj-1)*37)*12+10);
OutTextXY(331, 24+(GirqI-(GrqEj-1)*37)*12+2, Bajanord.GrqiAnun[GirqI]);
End;
End;
if (Button=3) and (Bajanord.Qanak<100) then
Begin
Bajanord.Qanak:=Bajanord.Qanak+1;
if Bajanord.Qanak>GrqEj*37 then
Begin
GrqEj:=GrqEj+1;
SetFillStyle(1, LightBlue);
Bar(329, 36, GetMaxX, GetMaxY);
End;
SetFillStyle(1, White); SetColor(Black);
Bar(329, 24+(GirqI-(GrqEj-1)*37)*12, 483, 24+(GirqI-(GrqEj-1)*37)*12+10);
OutTextXY(331, 24+(GirqI-(GrqEj-1)*37)*12+2, Bajanord.GrqiAnun[GirqI]);
SetFillStyle(1, LightGray);
Bar(329, 24+(Bajanord.Qanak-(GrqEj-1)*37)*12, 483, 24+(Bajanord.Qanak-(GrqEj-1)*37)*12+10);
SetColor(Black); s:='';
Repeat
C:=GetKey;
if (ord(C)>=65) and (ord(C)<=122) and (Length(s)<18) then
Begin
s:=s+C;
OutTextXY(331, 24+(Bajanord.Qanak-(GrqEj-1)*37)*12+2, s);
End
else if (C=BackSpace) and (s<>'') then
Begin
SetColor(LightGray);
OutTextXY(331, 24+(Bajanord.Qanak-(GrqEj-1)*37)*12+2, s);
SetColor(Black);
Delete(s, Length(s), 1);
OutTextXY(331, 24+(Bajanord.Qanak-(GrqEj-1)*37)*12+2, s);
End;
Until (C=ENTER) and (s<>'');
SetFillStyle(1, White); SetColor(Black);
Bar(329, 24+(Bajanord.Qanak-(GrqEj-1)*37)*12, 483, 24+(Bajanord.Qanak-(GrqEj-1)*37)*12+10);
OutTextXY(331, 24+(Bajanord.Qanak-(GrqEj-1)*37)*12+2, s);
Bajanord.GrqiAnun[Bajanord.Qanak]:=s; s:='';
SetFillStyle(1, LightGray);
Bar(485, 24+(Bajanord.Qanak-(GrqEj-1)*37)*12, 638, 24+(Bajanord.Qanak-(GrqEj-1)*37)*12+10);
Repeat
C:=GetKey;
if (ord(C)>=65) and (ord(C)<=122) and (Length(s)<18) then
Begin
s:=s+C;
OutTextXY(487, 24+(Bajanord.Qanak-(GrqEj-1)*37)*12+2, s);
End
else if (C=BackSpace) and (s<>'') then
Begin
SetColor(LightGray);
OutTextXY(487, 24+(Bajanord.Qanak-(GrqEj-1)*37)*12+2, s);
SetColor(Black);
Delete(s, Length(s), 1);
OutTextXY(487, 24+(Bajanord.Qanak-(GrqEj-1)*37)*12+2, s);
End;
Until (C=ENTER) and (s<>''); C:=NULL;
SetFillStyle(1, White); SetColor(Black);
Bar(485, 24+(Bajanord.Qanak-(GrqEj-1)*37)*12, 638, 24+(Bajanord.Qanak-(GrqEj-1)*37)*12+10);
OutTextXY(487, 24+(Bajanord.Qanak-(GrqEj-1)*37)*12+2, s);
Bajanord.GrqiHexinak[Bajanord.Qanak]:=s; s:='';
SetFillStyle(1, LightGray);
Bar(329, 24+GirqI*12, 483, 24+GirqI*12+10);
OutTextXY(331, 24+GirqI*12+2, Bajanord.GrqiAnun[GirqI]);
End;
Reset(f); Rewrite(g);
j:=0;
while Not Eof(f) do
Begin
j:=j+1;
Read(f, Baj);
if i<>j then
Write(g, Baj)
else
Write(g, Bajanord);
End;
Close(f); Close(g);
Reset(g); Rewrite(f);
while Not Eof(g) do
Begin
Read(g, Baj);
Write(f, Baj);
End;
Close(f); Close(g); Reset(f);
if GrqEj*37<Bajanord.Qanak then min:=GrqEj else min:=Bajanord.Qanak;
End;
Until C=ESC; C:=NULL;
GnalEj(ej);
SetColor(Brown);
Rectangle(240+(Button-1)*30, 1, 260+(Button-1)*30, 21);
SetColor(Yellow);
Rectangle(240, 1, 260, 21);
End;
Until C=ESC; C:=NULL;
SetFillStyle(1, White); str(i, s); SetColor(Red);
Bar(1, 24+(i-(ej-1)*37)*12, 25, 24+(i-(ej-1)*37)*12+10);
OutTextXY(1+(25-Length(s)*8)div 2, 24+(i-(ej-1)*37)*12+2, s);
Close(f);
End; {End of 'if MaxN>0'}
End; {Popoxel}
Procedure Hanel;
Var i, j, min : integer;
s : string[5];
f, g : file of Cucak;
Begin {Hanel}
if MaxN>0 then Begin
Assign(f, 'input.txt');
Assign(g, 'temp.txt');
i:=(ej-1)*37+1;
Repeat
SetFillStyle(1, LightGray); SetColor(Red); str(i, s); SetTextStyle(0, 0, 1);
Bar(1, 24+(i-(ej-1)*37)*12, 25, 24+(i-(ej-1)*37)*12+10);
OutTextXY(1+(25-Length(s)*8)div 2, 24+(i-(ej-1)*37)*12+2, s);
C:=GetKey; if ej*37<MaxN then min:=ej*37 else min:=MaxN;
if (C=DOWN) and (i<min) then
Begin
SetFillStyle(1, White); str(i, s); SetColor(Red);
Bar(1, 24+(i-(ej-1)*37)*12, 25, 24+(i-(ej-1)*37)*12+10);
OutTextXY(1+(25-Length(s)*8)div 2, 24+(i-(ej-1)*37)*12+2, s);
i:=i+1;
SetFillStyle(1, LightGray);
Bar(1, 24+(i-(ej-1)*37)*12, 25, 24+(i-(ej-1)*37)*12+10);
str(i, s);
OutTextXY(1+(25-Length(s)*8)div 2, 24+(i-(ej-1)*37)*12+2, s);
End
else if (C=UP) and (i>(ej-1)*37+1) then
Begin
SetFillStyle(1, White); str(i, s); SetColor(Red);
Bar(1, 24+(i-(ej-1)*37)*12, 25, 24+(i-(ej-1)*37)*12+10);
OutTextXY(1+(25-Length(s)*8)div 2, 24+(i-(ej-1)*37)*12+2, s);
i:=i-1;
SetFillStyle(1, LightGray);
Bar(1, 24+(i-(ej-1)*37)*12, 25, 24+(i-(ej-1)*37)*12+10);
str(i, s);
OutTextXY(1+(25-Length(s)*8)div 2, 24+(i-(ej-1)*37)*12+2, s);
End
else if C=ENTER then
Begin
Reset(f); Rewrite(g);
j:=0;
while Not Eof(f) do
Begin
j:=j+1;
Read(f, Bajanord);
if i<>j then
Write(g, Bajanord);
End;
Close(f); Close(g);
Reset(g); Rewrite(f);
while Not Eof(g) do
Begin
Read(g, Bajanord);
Write(f, Bajanord);
End;
Close(f); Close(g);
MaxN:=MaxN-1;
SetFIllStyle(1, LightBlue);
Bar(0, (i-(ej-1)*37)*12+24, GetMaxX, GetMaxY);
if ej*37<MaxN then min:=ej*37 else min:=MaxN;
Reset(f); seek(f, i-1);
for j:=i to min do
Begin
Read(f, Bajanord);
DrawLine((j-(ej-1)*37)*12+24);
FillLine((j-(ej-1)*37)*12+24, j, Bajanord);
End;
if i=MaxN+1 then i:=i-1;
if i<(ej-1)*37+1 then GnalEj(ej-1);
End;
Until (C=ESC) or (MaxN=0); C:=SPACE;
if i>0 then
Begin
SetFillStyle(1, White); str(i, s); SetColor(Red);
Bar(1, 24+(i-(ej-1)*37)*12, 25, 24+(i-(ej-1)*37)*12+10);
OutTextXY(1+(25-Length(s)*8)div 2, 24+(i-(ej-1)*37)*12+2, s);
End;
End; {End of 'if MaxN>0'}
End; {Hanel}
Procedure Avelacnel;
Var y, avelEjer : integer;
s : string[20];
f, g : file of Cucak;
Baj, Empty : Cucak;
Begin {Avelacnel}
Bajanord:=Empty;
MaxN:=MaxN+1;
GnalEj((MaxN-1) div 37 + 1);
y:=MaxN;
DrawLine(24+(y-(ej-1)*37)*12);
SetColor(Red); SetTextStyle(0, 0, 1);
str(MaxN, s);
OutTextXY(1+(25-Length(s)*8)div 2, (24+(y-(ej-1)*37)*12)+2, s);
SetFillStyle(1, LightGray);
Bar(27, (24+(y-(ej-1)*37)*12), 171, (24+(y-(ej-1)*37)*12)+10);
SetColor(Black); s:='';
Repeat
C:=GetKey;
if (ord(C)>=65) and (ord(C)<=122) and (Length(s)<18) then
Begin
s:=s+C;
OutTextXY(29, 24+(y-(ej-1)*37)*12+2, s);
End
else if (C=BackSpace) and (s<>'') then
Begin
SetColor(LightGray);
OutTextXY(29, 24+(y-(ej-1)*37)*12+2, s);
SetColor(Black);
Delete(s, Length(s), 1);
OutTextXY(29, 24+(y-(ej-1)*37)*12+2, s);
End;
Until (C=ENTER) and (s<>'');
SetFillStyle(1, White);
Bar(27, (24+(y-(ej-1)*37)*12), 171, (24+(y-(ej-1)*37)*12)+10);
OutTextXY(29, 24+(y-(ej-1)*37)*12+2, s);
Bajanord.Anun:=s;
SetFIllStyle(1, LightGray);
Bar(173, 24+(y-(ej-1)*37)*12, 327, 24+(y-(ej-1)*37)*12+10);
s:='';
Repeat
C:=GetKey;
if (ord(C)>=65) and (ord(C)<=122) and (Length(s)<18) then
Begin
s:=s+C;
OutTextXY(175, 24+(y-(ej-1)*37)*12+2, s);
End
else if C=BackSpace then
Begin
SetColor(LightGray);
OutTextXY(175, 24+(y-(ej-1)*37)*12+2, s);
SetColor(Black);
Delete(s, Length(s), 1);
OutTextXY(175, 24+(y-(ej-1)*37)*12+2, s);
End;
Until (C=ENTER) and (s<>'');
SetFillStyle(1, White);
Bar(173, 24+(y-(ej-1)*37)*12, 327, 24+(y-(ej-1)*37)*12+10);
OutTextXY(175, 24+(y-(ej-1)*37)*12+2, s);
Bajanord.Azganun:=s;
i:=0; y:=y-1; avelEjer:=0;
Repeat
i:=i+1; y:=y+1;
SetFillStyle(1, LightBlue);
if y>ej*37 then
Begin
ej:=ej+1; Bar(0, 36, GetMaxX, GetMaxY); AvelEjer:=AvelEjer+1;
DrawLine(36); SetColor(Red);
str(MaxN, s);
OutTextXY(1+(25-Length(s)*8)div 2, 38, s);
SetColor(Black);
OutTextXY(29, 38, Bajanord.Anun);
OutTextXY(175, 38, Bajanord.Azganun);
End;
SetFillStyle(1, LightGray);
Bar(329, 24+(y-(ej-1)*37)*12, 483, 24+(y-(ej-1)*37)*12+10);
s:='';
Repeat
C:=GetKey;
if (ord(C)>=65) and (ord(C)<=122) and (Length(s)<18) then
Begin
s:=s+C;
OutTextXY(331, 24+(y-(ej-1)*37)*12+2, s);
End
else if C=BackSpace then
Begin
SetColor(LightGray);
OutTextXY(331, 24+(y-(ej-1)*37)*12+2, s);
SetColor(Black);
Delete(s, Length(s), 1);
OutTextXY(331, 24+(y-(ej-1)*37)*12+2, s);
End;
Until (C=ENTER) and ((i>1) or (s<>''));
if s='' then Break;
SetFillStyle(1, White);
Bar(329, 24+(y-(ej-1)*37)*12, 483, 24+(y-(ej-1)*37)*12+10);
OutTextXY(331, 24+(y-(ej-1)*37)*12+2, s);
Bajanord.GrqiAnun[i]:=s;
SetFillStyle(1, LightGray);
Bar(485, 24+(y-(ej-1)*37)*12, 638, 24+(y-(ej-1)*37)*12+10);
s:='';
Repeat
C:=GetKey;
if (ord(C)>=65) and (ord(C)<=122) and (Length(s)<18) then
Begin
s:=s+C;
OutTextXY(487, 24+(y-(ej-1)*37)*12+2, s);
End
else if C=BackSpace then
Begin
SetColor(LightGray);
OutTextXY(487, 24+(y-(ej-1)*37)*12+2, s);
SetColor(Black);
Delete(s, Length(s), 1);
OutTextXY(487, 24+(y-(ej-1)*37)*12+2, s);
End;
Until (C=ENTER) and ((i>1) or (s<>''));
SetFillStyle(1, White);
Bar(485, 24+(y-(ej-1)*37)*12, 638, 24+(y-(ej-1)*37)*12+10);
OutTextXY(487, 24+(y-(ej-1)*37)*12+2, s);
if s='' then Bajanord.GrqiAnun[i]:=''
else Bajanord.GrqiHexinak[i]:=s;
Until (s='') and (i>1);
Bajanord.Qanak:=i-1;
Baj:=Bajanord;
GnalEj(ej-AvelEjer);
Bajanord:=Baj;
Assign(f, 'input.txt'); Reset(f);
Assign(g, 'temp.txt'); Rewrite(g);
while Not Eof(f) do
Begin
Read(f, Baj);
Write(g, Baj);
End;
Write(g, Bajanord);
Close(f); Close(g);
Rewrite(f); Reset(g);
while Not Eof(g) do
Begin
Read(g, Baj);
Write(f, Baj);
End;
Close(f); Close(g);
SetFillStyle(1, LightBlue);
Bar(0, 24+((MaxN-(ej-1)*37))*12, GetMaxX, GetMaxY);
DrawLine(24+((MaxN-(ej-1)*37))*12);
FillLine(24+((MaxN-(ej-1)*37))*12, MaxN, Bajanord);
End; {Avelacnel}
Begin
SetFillStyle(1, LightBlue);
Bar(0, 0, GetMaxX, GetMaxY);
Assign(f, 'input.txt'); Reset(f);
DrawLine(24);
SetTextStyle(0, 0, 1); SetColor(Black);
SetColor(LightRed);
OutTextXY(80, 26, 'Name');
OutTextXY(225, 26, 'Surname');
OutTextXY(390, 26, 'Book');
OutTextXY(540, 26, 'Author');
MaxN:=0; ej:=1;
while Not Eof(f) do
Begin
MaxN:=MaxN+1;
Read(f, Bajanord);
if MaxN<=37 then
Begin
DrawLine(24+MaxN*12);
FillLine(24+MaxN*12, MaxN, Bajanord);
End;
End;
SetFillStyle(1, Brown);
Bar(210, 1, 230, 21);
Bar(240, 1, 260, 21);
Bar(270, 1, 290, 21);
Bar(300, 1, 320, 21);
Bar(330, 1, 350, 21);
Bar(360, 1, 380, 21);
SetColor(Yellow); SetTextStyle(0, 0, 2);
OutTextXY(214 , 5, '?');
OutTextXY(244 , 1, '-');
OutTextXY(244 , 5, '-');
OutTextXY(244 , 9, '-');
OutTextXY(274 , 5, '-');
OutTextXY(304 , 5, '+');
OutTextXY(334 , 5, '< >');
SetLineStyle(0, 0, 1);
Rectangle(240, 1, 260, 21);
Button:=1;
Repeat
C:=GetKey;
if C=RIGHT then
Begin
SetColor(Brown); SetLineStyle(0, 0, 1);
Rectangle(240+(Button-1)*30, 1, 260+(Button-1)*30, 21);
Button:=Button+1;
if Button=6 then Button:=0;
SetColor(Yellow);
Rectangle(240+(Button-1)*30, 1, 260+(Button-1)*30, 21);
End
else if C=LEFT then
Begin
SetColor(Brown); SetLineStyle(0, 0, 1);
Rectangle(240+(Button-1)*30, 1, 260+(Button-1)*30, 21);
Button:=Button-1;
if Button<0 then Button:=5;
SetColor(Yellow);
Rectangle(240+(Button-1)*30, 1, 260+(Button-1)*30, 21);
End
else if C=ENTER then
case Button of
0 : Nayel;
1 : Popoxel;
2 : Hanel;
3 : Avelacnel;
4 : GnalEj(ej-1);
5 : GnalEj(ej+1);
End;
Until C=ESC;
Close(f);
End;
Begin {Main}
dr:=0;
InitGraph(dr, md, '');
Menu; elq:=false;
Repeat
C:=GetKey;
if C=UP then
Begin
SetColor(LightBlue); SetLineStyle(0, 0, 3);
Line(224, 80+But*60, 416, 80+But*60);
But:=But-1;
if But=0 then But:=4;
SetColor(Blue);
Line(224, 80+But*60, 416, 80+But*60);
End
else if C=DOWN then
Begin
SetColor(LightBlue); SetLineStyle(0, 0, 3);
Line(224, 80+But*60, 416, 80+But*60);
But:=But+1;
if But=5 then But:=1;
SetColor(Blue);
Line(224, 80+But*60, 416, 80+But*60);
End
else if C=ENTER then
Begin
case But of
1 : Problem;
2 : InDat;
3 : Solution;
4 : elq:=true;
End;
Menu;
End;
Until elq;
End. {Main}