uses graph crt procedure DrawGraph kol integer mas1 array of real mas2

  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
uses graph,crt;
procedure DrawGraph(kol:integer;mas1:array of real;mas2:array of real);
var x,y,driver,mode,rez,i,lenx,leny,grx,gry,depth:integer;
max,kx,ky:real;
points1:array[1..14] of integer;
points2:array[1..14] of integer;
st:string;
begin
driver:=9;
mode:=2;
initgraph(driver,mode,'');
x:=getmaxx;
y:=getmaxy;
grx:=x div 13;
gry:=y*11 div 12;
setcolor(15);
settextstyle(8,0,1);
settextjustify(1,2);
outtextxy(x div 2,5,'2 Diagrammy');
setcolor(2);
line(grx,y-gry,grx,gry);
line(grx,y-gry,round(grx*1.1),round((y-gry)*1.3));
line(grx,y-gry,round(grx*0.9),round((y-gry)*1.3));
line(grx,gry,x-grx,gry);
line(x-grx,gry,round(x-grx*1.3),round(gry*1.01));
line(x-grx,gry,round(x-grx*1.3),round(gry*0.99));
lenx:=x*10 div 13;
leny:=y*3 div 4;
max:=mas1[0];
for i:=0 to kol-1 do
begin
if mas1[i]>max then max:=mas1[i];
if mas2[i]>max then max:=mas2[i];
end;
ky:=max/leny;
kx:=lenx/(4*kol);
depth:=round(kx/1.5);
settextstyle(0,0,1);
settextjustify(2,1);
for i:=1 to 10 do
begin
line(round(grx*0.9),gry-(leny*i div 10),round(grx*1.1),gry-(leny*i div 10));
line(grx,gry-(leny*i div 10),grx+depth*2,gry-(leny*i div 10)-round(depth*1.65));
line(grx+depth*2,gry-(leny*i div 10)-round(depth*1.65),grx+depth*2+lenx,gry-
(leny*i div 10)-round(depth*1.65));
str(round(max*i),st);
st:=copy(st,0,length(st)-1)+'.'+st[length(st)];
setcolor(15);
outtextxy(round(grx*0.9),gry-(leny*i div 10),st);
setcolor(2);
end;
line(grx,gry,grx+depth*2,gry-round(depth*1.65));
line(grx+depth*2,gry-round(depth*1.65),grx+depth*2+lenx,gry-round(depth*1.65));
for i:=0 to kol-1 do
begin
points1[1]:=grx+round(kx*(4*i+3));
points1[2]:=gry-round(depth*0.15);
points1[3]:=points1[1]+depth;
points1[4]:=points1[2]-round(depth*0.6);
points1[5]:=points1[3];
points1[6]:=points1[4]-round(mas1[i]/ky);
points1[7]:=points1[5]-round(2*kx);
points1[8]:=points1[6];
points1[9]:=points1[7]-depth;
points1[10]:=points1[8]+round(depth*0.6);
points1[11]:=points1[9]+round(2*kx);
points1[12]:=points1[10];
points2[1]:=grx+round(kx*(4*i+4.5));
points2[2]:=gry-round(depth*1.2);
points2[3]:=points2[1]+depth;
points2[4]:=points2[2]-round(depth*0.6);
points2[5]:=points2[3];
points2[6]:=points2[4]-round(mas2[i]/ky);
points2[7]:=points2[5]-round(2*kx);
points2[8]:=points2[6];
points2[9]:=points2[7]-depth;
points2[10]:=points2[8]+round(depth*0.6);
points2[11]:=points2[9]+round(2*kx);
points2[12]:=points2[10];
setcolor(10);
setfillstyle(1,10);
bar(grx+round(kx*(4*i+2.5)),gry-round(depth*1.2),grx+round(kx*(4*i+4.5)),gry-round(mas2[i]/ky+depth*1.2));
setfillstyle(1,2);
fillpoly(6,points2);
line(points2[11],points2[12],points2[5],points2[6]);
setcolor(12);
setfillstyle(1,12);
bar(grx+round(kx*(4*i+1)),gry-round(depth*0.15),grx+round(kx*(4*i+3)),gry-round(mas1[i]/ky+depth*0.15));
setfillstyle(1,4);
fillpoly(6,points1);
line(points1[11],points1[12],points1[5],points1[6]);
setcolor(15);
str(i+1,st);
outtextxy((points1[9]+points1[11]) div 2,round(gry*1.02),st);
end;
outtextxy(grx-10,round(gry*1.02),'0');
outtextxy(grx-2,y-gry-5,'Y');
outtextxy(x-grx+10,gry,'X');
end;
var kol:integer;
dat:real;
f:text;
diag1:array [0..19] of real;
diag2:array [0..19] of real;
st:string;
begin
clrscr;
assign(f,'input.txt');
reset(f);
kol:=0;
while not eof(f) do
begin
read(f,diag1[kol]);
read(f,diag2[kol]);
kol:=kol+1;
end;
DrawGraph(kol,diag1,diag2);
readkey;
end.