1 program lomena_cara;
2
3 type Tbod=array['x'..'y'] of real;
4 Tsouradnice= array [1..2] of Tbod;
5
6 var i:integer;
7 souradnice:Tsouradnice;
8 anone:char;
9 x,y,delka:real;
10
11 begin
12 writeln('****** Program pro výpočet délky lomené čáry *******');
13 writeln('Zadej postupně všechny body, ktrerými čáre prochází');
14 writeln;
15 writeln('Zadej první bod');
16 write('X: '); read(souradnice[1,'x']); write('Y: '); readln(souradnice[1,'y']);
17 delka:=0;
18 repeat begin
19 writeln('*** Zadej další bod ***');
20 write('X: '); read(souradnice[2,'x']); write('Y: '); readln(souradnice[2,'y']);
21 x:=souradnice[1,'x']-souradnice[2,'x'];
22 y:=souradnice[1,'y']-souradnice[2,'y'];
23 delka:=delka + sqrt(sqr(x)+sqr(y));
24 souradnice[1]:=souradnice[2]; { přesunu souřadnici 2 na pozici 1 a souradnici 1 }
25 writeln('Délka je: ', delka:5:2); { v příštím průchodu cyklem znovu načtu (řádek 20) }
26 write('Chceš zadat ječtě jeden bod? A/n [A]:'); readln(anone);
27 end until ((anone='n')or(anone='N'))
28 end.