Решение задачи о кратчайшем маршруте

Ia i?aeoeea ?anoi
ano?a?aaony caaa?a ii?aaaeaiey e?ao?aeoaai ia?o?ooa ii caaaiiie naoe ec
ia?aeuiiai ioieoa ai eiia?iiai ioieoa ia?o?ooa. O?ainii?oiay naou ii?ao auou
i?aanoaaeaia a aeaa a?aoa (?en.1), aoae eioi?iai - o?ainii?oiua iaaeno?aee, a
oceu - ioieou ioi?aaeaiey e iacia?aiey. A?aoe?anee o?ainii?oiay naou
ecia?a?aaony a aeaa niaieoiiinoe n ioieoia
P ) ioieoia iacia?aiey niaaeiaiu aoaaie caaaiiie
aeeiiu .
Iaeioi?ua eee ana aoae iiaoo auou i?eaioe?iaaiu, o.a. ii iei aicii?ii aae?aiea
oieuei a iaiii iai?aaeaiee, oeacaiiii no?aeeaie. ,...,P Iaiaoiaeii ii?aaaeeou e?ao?aeoee ia?o?oo ec
ioieoa P . Ii?aaaeaiea e?ao?aeoaai ia?o?ooa ninoieo a
oeacaiee iineaaiaaoaeuiinoe i?ioi?aaiey ia?o?ooa ?a?ac i?iia?ooi?iua ioieou e
noiia?iie aeeiiu ia?o?ooa. ;
L=l Iinoaiiaea caaa?e
i?eia?aoaao niune a oii neo?aa, anee eiaaony ianeieuei aa?eaioia ia?o?ooa ec
ia?aeuiiai ioieoa a eiia?iue. A yoii neo?aa oece?aneee niune ooieoee oaee caaa?e
ninoieo a ieieiecaoee iauae aeeiiu ia?o?ooa, o.a. a ii?aaaeaiee e?ao?aeoaai iooe
ec P Iaoia Oi?aa aae ?ac?aaioai niaoeaeuii aey ?aoaiey naoaauo
o?ainii?oiuo caaa? e iniiaai, ii nouanoao, ia i?eioeia iioeiaeuiinoe. Aeai?eoi
iaoiaa Oi?aa niaa??eo ?aou?a yoaia (noaia 1). Ia ia?aii yoaia i?iecaiaeony
caiieiaiea enoiaiie oaaeeou ?annoiyiee io e?aiai i-ai ioieoa a e?aie a?oaie j-e
ioieo iacia?aiey. Ia aoi?ii yoaia ii?aaaey?ony aey ea?aiai ioieoa iaeioi?ua
ia?aiao?u ii niioaaonoao?uei oi?ioeai. Aaeaa ia
o?aouai yoaia ii?aaaey?ony e?ao?aeoea ?annoiyiey. Iaeiiao, ia ?aoaa?oii yoaia
ii?aaaey?ony e?ao?aeoea ia?o?oou ec ioieoa ioi?aaeaiey ? ?anniio?ei iia?iaiaa
ea?aue ec yoeo ?aou?ao yoaiia. Aaiiay oaaeeoa niaa??eo n+1 no?ie e oaeia ?a eiee?anoai
noieaoia; P - ioieou iacia?aiey.
Ai aoi?ie no?iea e aoi?ii noieaoa i?inoaaeyaony cia?aiey ia?aiao?ia , ii?aaaeaiea cia?aiee eioi?uo
i?iecaiayony ia aoi?ii yoaia ?aoaiey caaa?e. A inoaeuiuo eeaoeao oaaeeou
i?inoaaey?ony cia?aiey ?annoiyiee l ec i-ai ioieoa a j-e ioieo.
I?e?ai caiieiyai eeaoee oaaeeou, ea?auea auoa aeaaiie aeaaiiaee. Anee ioieo
P 2.2 Aoi?ie yoai: Ii?aaaeaiea
Ii?aaaeyaony cia?aiea
ia?aiao?ia a niioaaonoaee n oi?ioeie: ); i=1,2,...,n;
j=1,2,...,n, (1) Yoe
cia?aiey caiieiy?ony ai aoi?ie no?iea e ai aoi?ii noieaoa. Aicii?iu aaa neo?ay ii?aaaeaiey
aeeiiu e?ao?aeoeo iooae ec ioieoia Pi a ioieou P l ; l oi cia?aiey ia?aiao?ia oaiaeaoai?y?o oneiaeyi iioeiaeuiinoe.
Ea?aia cia?aiea ai ioieoa P ; i=1,...,n;
j=1,...,n, (3) iiaoo auou oiaiuoaiu. , ia?an?eoaa aai ii oi?ioea: Ii?aaaeaiey
iineaaiaaoaeuiinoe ioieoia e?ao?aeoaai ia?o?ooa. N yoie oaeu? aey ea?aiai
noieaoa ii?aaaey?o aaee?eio: , (5) auae?aaony oae,
?oiau auiieieeinu ?aaainoai (5). Oaeei ia?acii ii?aaaeei r1. Aaeaa i?iaie?ei oo
?a iia?aoe?, ii aoaai n?eoaou, iineaaiae ia P Oaeei ia?acii
e?ao?aeoee ia?o?oo i?ioiaeo ?a?ac
P rn-1,rn I?ia?aiia "FORD" iaienaia ia ycuea aunieiai o?iaiy - Pascal,
a eioaa?e?iaaiiie n?aaa ?ac?aaioee "Turbo Pascal 7.0" oe?iu Borland
Inc. I?ia?aiia i?aaiacia?aia aey iaoi?aaiey e?ao?aeoaai iooe a naoaaii
a?aoa ii iaoiao Oi?aa. I?ia?aiia eaaea a eniieuciaaiee, ?oi ainoeaaaony ca n?ao
eniieuciaaiey a?o?anoaaiiiai eioa?oaena e ea?a?oe?aneiai iai?. Aia?aea i?ia?aiiu
i?iecaiaeony aaia aaiiuo, caoai iaoi?aaiea e?ao?aeoaai ia?o?ooa e au?eneaiea aai
aeeiiu, aaeaa auaiaeony ?acoeuoao. Auaia ?acoeuoaoia aicii?ai eae a oaee, oae e
ia ye?ai. 4. Iienaiea iiai?ia?aii e
i?ioaao?. IACIA?AIEA Au?eneyao ieieiaeuiia cia?aiea aaeoi?a k[i]; Onoaiaaeeaaao a?aoe?aneee ?a?ei; Eieoeaeece?oao iaiiu; I?ioaao?a ?eniaaiey iaiy; Auaiaeo niiauaiea i ei??aeoiinoe
iia?aoee; Auaiaeo niiauaiea i iaei??aeoiinoe
iia?aoee; I?iaa?yao ei??aeoiinou
aaiaa aaiiuo; Aaia enoiaiuo aaiiuo n
eeaaeaoo?u; Auaiaeo ?aieo ii e?ayi
ye?aia; Nio?aiaiea ?acoeuoaoia a
oaee; Auaiaeo eioi?iaoe? i
i?ia?aiia; Auaiaeo eioi?iaoe? i iaoiaa
Oi?aa; ?enoao aa?oeiu
a?aoa; ?enoao aoae
a?aoa; ?enoao e?ao?aeoee
ia?o?oo; Au?eneyao ye?aiiua
eii?aeiaou aa?oei a?aoa; Eieoeaeece?oao o?eoo iieuciaaoaey; Iniiaiia iaoaiaoe?aneia ya?i i?ia?aiiu; Ioe?uoea iai?; Cae?uoea iai?; Iniiaiie iaoaieci iai?; Noaaeo oi?eo; Eieoeaeece?oao iannea ni caacaaie; Canoaaea; Iienuaaao iai?
i?ia?aiiu Iienuaaao iai? i?ia?aiiu Iienuaaao iai? i?ia?aiiu Eiy
oaeea aoiaiuo aaiiuo Eiy oaeea auoiaiuo
aaiiuo array of real integer integer integer integer integer integer integer integer integer integer array of
real Eiau ioeaie i?e aaiaa aaiiuo O?aieo oaaoa iaiy Iao?eoa i?iia?ooi?iuo
aaiiuo Eniieucoaony i?e au?eneaiee eii?aeiao aa?oei
a?aoa Eniieucoaony i?e au?eneaiee eii?aeiao aa?oei
a?aoa Eni. i?e
ii?aaaeaiee e?ao?aeoaai ia?o?ooa TRUE, anee aaiiua aaiaeeenu TRUE, anee aaiiua aeee ia?aaioaiu Eniieucoaony a i?ioaao?a iai? Eniieucoaony i?e aaiaa n eeaaeaoo?u O?aieo
a?aiaiiia cia?aiea Eii?aeiaou eo?ni?a
iai? Iineaaiea eii?aeiaou eo?ni?a
iai? Eniieucoaony i?e aaiaa n
eeaaeaoo?u 5. I?eia?u ?aoaiey eiio?ieuiuo
caaa?. j 2 X Iinea ia?aaioee oaaeeou n caaaiiuie
enoiaiuie aaiiuie, i?ia?aiia auaaao neaao?uea ?acoeuoaou: Enoiaiay oaaeeoa
?annoiyiee aey iaiiai ec aa?eaioia ia ?ai?e?iaaiiiai a?aoa: /P X 9 Iinea ia?aaioee oaaeeou n caaaiiuie
enoiaiuie aaiiuie, i?ia?aiia auaaao neaao?uea ?acoeuoaou: I?ia?aiia
?aaioiniiniaia i?e e?auo a?oaeo aa?eaioao enoiaiuo aaiiuo. Aiaeec aeai?eoia iia?aoee, iaiaoiaeiuo i?e ?aoaiee naoaaie
o?ainii?oiie caaa?e iaoiaii Oi?aa a caaaiiie iinoaiiaea
iiaoaa??aaao: Ea?aue yoai iienuaaaony i?inouie iaoaiaoe?aneeie iia?aoeyie e ii?ao
auou caienai ia iaiii ec ycueia i?ia?aiie?iaaiey. Ninoaaeaia i?ia?aiia ia
aeai?eoie?aneii ycuea aunieiai o?iaiy "Pascal", iicaiey?uay ?aoaou caaa?o a
aeaeiaiaii ?a?eia, oaiaiii aey iieuciaaoaey ia i?ia?aiienoa. Aeai?eoi ?aoaiey
o?ainii?oiie caaa?e iaoiaii Oi?aa yaeyaony oieaa?naeuiui, ?oi iicaieyao
i?iecaiaeou ?an??ou eae n ?ai?e?iaaiiuie, oae e n ia ?ai?e?iaaiiuie a?aoaie
(i?eia?u ?aoaiey caaa?e i?eaaaaiu ia no?aieoa 11). Aicii?iinou
iaiaiie?aoiiai ?aoaiey caaa?e iaoiaii Oi?aa i?e ?acee?iuo enoiaiuo
aaiiuo. (('Aaia aaiiuo','?aoaiea caaa?e','Auaia
?acoeuoaoa', ('Ye?ai','Oaee','Iacaa','','',''),
menuof:array[0..4] of byte =(6,3,3,3,2);
name1='input.dat'; col:array[16..31] of
byte=(0,186,113,4,40,41,41,42,42,43,44,69,15,15,15,15); ' ENNEAAIAAIE?
IIA?AOEE ', ' ', ' Iaoia Oi?aa ');
coord_point:coord; result:array[1..20] of integer; mask:array[1..6] of byte;
aa,cc,pi1,s:real; pressed:char; if (s=0) and (k[i]<>-1) then s:=k[i] PROCEDURE
set_graph_mode; mov es,ax PROCEDURE
install_firewall;
begin pixel(j*2+xx1,i*3+yy1-2,col[fire1[i,j]]); else fire1[yyy,j]:=round(31-kk);
fire2[i,j]:=round((fire1[i+1,j]+fire1[i+1,j-1]+fire1[i+1,j+1]-random(4))/3); for j:=1 to xxx do rectangle(120,100,520,220
); outtextxy(250,160,'ei??aeoii.'); rectangle(120,100,520,
220); outtextxy(230,160,'ia ei??aeoii.'); for i:=1 to 5 do if mas[n,i]<>-1 then error_code[2]:=1; if (mas[i,j]<0) and
(mas[i,j]<>-1) then error_code[5]:=1; if
error_code[2]<>0 then writeln('Ioeaea: Nouanoaoao aoaa ec iaiie aa?oeiu
a oo ?a aa?oeio.'); if error_code[5]<>0
then if error_code[i]<>0 then inputdata:=false; write('Aaaa
eoa eieee?anoai ioieoia(2-20): '); if (z<>0)
or (round(n)<>n) or (n<2) or (n>20) then
check_input_data; for j:=i to n do readln(o); check_input_data; PROCEDURE
ramka; ; for i:=1 to lenth do write(f2,round(mas[0,n])); settextstyle(chrus,0,5); outtextxy(40,100,'I?ia
?aiia: '); outtextxy(40,265,'Aaoa:
'); outtextxy(200,150,'v1.0'); outtextxy(200,215,'aiaaiey
iie?aoee"'); outtextxy(50,395,'aey aieuoae eioi?iaoee niio?eoa
README.TXT'); settextstyle(chrus,0,5); outtextxy(40,90,'Iaoia
Oi?aa aue ?ac?aaioai niaoeaeuii aey'); outtextxy(50,130,'aai, ii nouanoao ia i?eioeia
iioeiaeuiinoe.'); outtextxy(50,170,'Ia ia?aii yoaia i?iecaiaeony caiieiaiea en-
'); outtextxy(50,210,'ioieoa a e?aie a?oaie j-e ioieo
iacia?aiey'); outtextxy(50,250,'ioieoa iaeioi?ua ia?aiao?u Ai e Aj ii niio-
'); outtextxy(50,290,'o?aouai yoaia ii?aaaeyaony e?ao?aeoaa ?an-
'); outtextxy(50,330,'aaey?ony e?ao?aeoea ia?o?oou ec
ioieoa'); repeat until
keypressed; begin str(i,o); else
outtextxy(round(coord_point[i,1]-7), PROCEDURE
draw_ways; y2:=round(coord_point[j,2]); outtextxy(round((x1+x2)/2+5),round((y1+y2)/2+5),o); begin y1:=round(coord_point[x,2]); settextstyle(chrus,0,1); str(result[lenth-
i+1],o); str(round(mas[0,n]),o); m:=0; coord_point[i,2]:=(sin(aa)*150)+200; chrus:=installuserfont('fn03'); k[i]:=0; if (mas[0,i]<>-1) and
(mas[i,j]<>-1) repeat if (mas[0,j]-
mas[0,i]>mas[i,j]) and (mas[i,j]<>-1) then t:=0; if
(mas[i,j]<>-1) and (i<>j) and (mas[i,j]=mas[0,j]-mas[0,i]) until
j=1; begin end
putpixel(starx[i],stary[i],starc[i]); line(210+i,110,210+i,110); setcolor(8); for
j:=1 to nline do for j:=nline*30+10 downto 1 do if j<10 then end draw_menu; outtextxy(220,110+(cursor-
1)*25,menu[menulevel,cursor]); if (pressed=#80) and
(cursor=nline) then if (pressed=#72) and (cursor=1)
then if (pressed=#80) and (cursor<nline) and not(move) then if
(pressed=#72) and (cursor>1) and not(move) then redraw_menu; if (cursor=1) and (menulevel=3)
then keyboard_input; if (cursor=2) and (menulevel=1) and
(inputdata=false) then notok; output_graph; if (cursor=2) and (menulevel=0) and (inputdata=false) then
notok; if (cursor=1) and (menulevel=2) and (calculatedata=true) then if (cursor=2) and (menulevel=2) and (calculatedata=true) then
save; if (cursor=2) and (menulevel=3) then
notok; PROCEDURE
welcomescreen; begin inputdata:=false; welcomescreen;