Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Информационная система железнодорожной сети / INPUT
.PASunit Input;
interface
uses Types, GrafUtil, crt;
{। ЄвЁа®ў ЁҐ ¬ аиагв®ў. ‚Є«оз Ґв ЇҐаҐЁ¬Ґ®ў ЁҐ бв жЁ©, Ё§¬ҐҐЁҐ бЇЁбЄ
бв жЁ© Ё ᮥ¤ЁҐЁ© ¬Ґ¦¤г бв жЁп¬Ё}
procedure EditRoutes(var g:TGraph);
{Їа®б¬®ва ¬ аиагв®ў}
procedure ViewRoutes(const g:TGraph);
{б®еа ҐЁҐ ¬ аиагв®ў}
procedure SaveRoutes(var f:text; const G:TGraph);
{§ Јаг§Є ¬ аиагв®ў}
procedure LoadRoutes(var f:Text; var G:TGraph);
{। ЄвЁа®ў ЁҐ а бЇЁб Ёп}
procedure EditTimeTable(var G:TGraph; view:boolean);
{ўлЎ®а бв жЁЁ Ё§ бЇЁбЄ }
function SelectStation(const G:TGraph):byte;
{ўў®¤ ўаҐ¬ҐЁ ®вЇа ў«ҐЁп б Їа®ўҐаЄ®©}
function SelectTime:TTime;
{ ©вЁ б ¬л© Ўлбвал© Їгвм Ё ўлўҐбвЁ ҐЈ® нЄа }
procedure FindShowWay(var G:TGraph; var way:TWay; vFrom, vTo:byte; DepTime:TTime; cheap:boolean);
implementation
procedure EditRoutes(var G:TGraph);
{ЇҐаҐ¬ҐйҐЁҐ Єгаб®а ў ¬ ваЁжҐ ᬥ¦®б⥩}
procedure MoveCursor(const G:TGraph; baseX,baseY,x0,y0,x1,y1:byte);
var l:byte;
begin
TextBackGround(black);
gotoxy(1, baseY+G.Number+2);
clreol;
if x1<>y1 then {Ї®¤ЇЁбм Ї®¤ в Ў«ЁжҐ© ®Ў ЄвЁў®© Є«ҐвЄҐ в Ў«Ёжл}
begin
WriteStr(G.Vertices[x1].Name,l);
gotoxy(l+1, WhereY);
if Connected(G,x1,y1) then write(' ')
else write(' Ґ ');
write('ᮥ¤ЁҐ б ');
WriteStr(G.Vertices[y1].Name,l);
end;
TextColor(white); {ў § ўЁбЁ¬®бвЁ ®в «ЁзЁп ᮥ¤ЁҐЁп аЁб㥬 Єгаб®а}
gotoxy(baseX+3*y0,baseY+x0);
if Connected(G,x0,y0) then TextBackGround(yellow)
else if (x0=y0) then TextBackGround(lightgray) else TextBackGround(black);
write(' ');
gotoxy(baseX+3*y1,baseY+x1);
if Connected(G,x1,y1) then TextBackGround(yellow)
else if (x1=y1) then TextBackGround(lightgray) else TextBackGround(black);
write('юю');
TextColor(lightgray);
end;
var n:byte;
c,cc:char;
i,j,bx,by:byte;
t:ArrString;
label addnewstation, start, quit, renamestation;
begin
start:
clrscr;
writeln('ђҐ¦Ё¬ а Ў®вл: ¤¬ЁЁбва в®а -> । ЄвЁа®ў ЁҐ ¬ аиагв®ў');
writeln('ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД');
writeln;
writeln('1) ЏҐаҐЁ¬Ґ®ў ЁҐ бв жЁ©');
writeln('2) €§¬ҐҐЁҐ бЇЁбЄ бв жЁ©');
writeln('3) €§¬ҐҐЁҐ ¬ аиагв®ў');
c:=readkey;
case c of
#27:begin
goto quit
end;
#49:begin
clrscr;
writeln('ђҐ¦Ё¬ а Ў®вл: ¤¬ЁЁбва в®а -> । ЄвЁа®ў ЁҐ ¬ аиагв®ў -> ЇҐаҐЁ¬Ґ®ў ЁҐ');
writeln('ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД');
writeln;
if G.Number=0 then
begin
writeln('Ѓ § Ґ ᮤҐа¦Ёв Ё ®¤®© бв жЁЁ.');
readln
end
else begin
writeln(' ‘в алҐ §ў Ёп і Ќ®ўлҐ §ў Ёп');
for i:=1 to G.Number do {бЇЁб®Є Ё¬ҐойЁебп бв жЁ©}
begin
write(i:2,': ');
WriteStr(G.Vertices[i].name,n);
writeln;
end;
i:=0;
renamestation:
inc(i);
gotoxy(40,4+i);
clreol;
write('і',i:2,': ');
t:=G.Vertices[i].Name;
WriteStr(t,n); {Є®ЇЁа®ў ЁҐ бв а®Ј® §ў Ёп бв жЁЁ}
repeat
cc:=readkey;
if cc=#8 then
begin {backspace}
if n<>0 then
begin
G.Vertices[i].Name[n]:=#0;
dec(n);
gotoxy(wherex-1,wherey);
clreol
end;
end
else begin
if (n<>MaxLength) and (cc<>#27) and (cc<>#13) then
begin
write(cc);
inc(n);
G.Vertices[i].Name[n]:=cc
end;
end;
until (cc=#27) or ((cc=#13) and (n<>0));
if (cc=#13) and (i<G.Number) then goto renamestation
else if (cc=#27) then goto start;
end;
end;
#50:begin
clrscr;
{RemoveAllConnections(G);}
writeln('ђҐ¦Ё¬ а Ў®вл: ¤¬ЁЁбва в®а -> । ЄвЁа®ў ЁҐ ¬ аиагв®ў -> бЇЁб®Є бв жЁ©');
writeln('ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД');
writeln;
writeln('‚Ќ€ЊЂЌ€…! ’®«мЄ® ®ўлҐ бв жЁЁ ў®бпвбп ў бЇЁб®Є');
writeln('—в®Ўл бЄ®ЇЁа®ў вм §ў ЁҐ бв а®© бв жЁЁ ¦¬ЁвҐ <TAB>');
writeln;
writeln(' ‘в алҐ бв жЁЁ і Ќ®ўлҐ бв жЁЁ');
for i:=1 to G.Number do
begin
write(i:2,': ');
WriteStr(G.Vertices[i].name,n);
writeln;
end;
G.Number:=0;
i:=0;
addnewstation:
inc(i);
gotoxy(40,7+i);
clreol;
write('і',i:2,': ');
t:=G.Vertices[i].Name;
for n:=1 to MaxLength do G.Vertices[i].Name[n]:=#0;
n:=0;
repeat
cc:=readkey;
case cc of
#8 :begin {backspace}
if n<>0 then
begin
G.Vertices[i].Name[n]:=#0;
dec(n);
gotoxy(wherex-1,wherey);
clreol
end;
end;
#9 :begin {tab}
gotoxy(45,7+i);
clreol;
WriteStr(t,n);
G.Vertices[i].Name:=t
end;
else begin
if (n<>MaxLength) and (cc<>#27) and (cc<>#13) then
begin
write(cc);
inc(n);
G.Vertices[i].Name[n]:=cc
end;
end;
end; {case}
until (cc=#27) or ((cc=#13) and (n<>0));
if (cc=#13) and (i<MaxStations) then goto addNewStation
else if (cc=#27) then
begin
ResizeGraph(G,i);
goto start;
end;
end; {1}
#51:begin
clrscr;
writeln('ђҐ¦Ё¬ а Ў®вл: ¤¬ЁЁбва в®а -> । ЄвЁа®ў ЁҐ ¬ аиагв®ў -> ¬ аиагвл');
writeln('ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД');
if G.Number=0 then
begin
writeln('Ѓ § Ґ ᮤҐа¦Ёв Ё ®¤®© бв жЁЁ.');
readln
end
else begin
writeln('‘ЇЁб®Є бв жЁ©:');
for i:=1 to G.Number do
begin
write(i:2,': ');
WriteStr(G.Vertices[i].name,n);
writeln
end;
writeln;
writeln('Њ ваЁж ᮥ¤ЁҐле бв жЁ©');
writeln('€бЇ®«м§г©вҐ бв५ЄЁ Ё <Їа®ЎҐ«> ¤«п Ё§¬ҐҐЁп ᮥ¤ЁҐЁп бв жЁ©');
writeln('---------------------------------------------------------------');
write(' і');
bx:=wherex-3;
by:=wherey;
for i:=1 to G.Number do write(i:2,'і');
writeln;
for i:=1 to G.Number do
begin
write(i:2,'і');
for j:=1 to G.Number do
begin
if i=j then TextBackGround(lightgray)
else if Connected(G,i,j) then TextBackGround(yellow)
else TextBackGround(black);
write(' ');
TextBackground(black);
write('і');
end;
writeln;
end;
for i:=0 to G.Number do write('---');
writeln;
i:=1; j:=1;
MoveCursor(G,bx,by,i,j,i,j);
repeat
cc:=readkey;
case cc of
#72:begin {up}
if i<>1 then
begin
MoveCursor(G,bx,by,i,j,i-1,j);
dec(i);
end;
end;
#80:begin {down}
if i<>G.Number then
begin
MoveCursor(G,bx,by,i,j,i+1,j);
inc(i);
end;
end;
#75:begin {left}
if j<>1 then
begin
MoveCursor(G,bx,by,i,j,i,j-1);
dec(j);
end;
end;
#77:begin {right}
if j<>G.Number then
begin
MoveCursor(G,bx,by,i,j,i,j+1);
inc(j);
end;
end;
#32:begin {space}
if Connected(G,i,j) then RemoveConnection(G,i,j)
else SetConnection(G,i,j);
MoveCursor(G,bx,by,i,j,j,i);
MoveCursor(G,bx,by,j,i,i,j);
end;
end;
until cc=#27;
end;
end; {2}
end; {case}
quit:
TextBackGround(black);
end; {proc}
{ўлЇЁблў Ґв бЇЁб®Є Ё¬Ґ бв жЁ©, б Є®в®ал¬Ё ᮥ¤ЁҐ ¤ п,
ў Є зҐб⢥ १г«мв в ў®§ўа й Ґв Ёе Є®«ЁзҐбвў®}
function ShowConnections(const G:TGraph; index:byte):byte;
var t:PDestination;
l,c:byte;
begin
clrscr;
t:=G.Vertices[index].Connections;
c:=0;
if t=nil then writeln(' €§®«Ёа®ў ')
else
while t<>nil do
begin
write(' ');
WriteStr(G.Vertices[t^.Where].Name,l);
writeln;
t:=t^.NextStation;
inc(c)
end; {while}
ShowConnections:=c;
end; {proc}
{Їа®б¬®ва ¬ аиагв®ў.
‚ «Ґў®© Є®«®ЄҐ бЇЁб®Є Ё¬Ґ бв жЁ©, ЇаЁ ЇҐаҐ¬ҐйҐЁЁ Ї® Є®в®а®¬г ў Їа ў®©
Є®«®ЄҐ ўЁ¤Ґ бЇЁб®Є бв жЁ©, б Є®в®ал¬Ё Ґбвм ЇаאַҐ б®®ЎйҐЁҐ Ё§ ⥪г饩}
procedure ViewRoutes(const g:TGraph);
var i,j:byte;
c:char;
begin
clrscr;
writeln('ђҐ¦Ё¬ а Ў®вл: ¤¬ЁЁбва в®а -> Їа®б¬®ва ¬ аиагв®ў');
writeln('ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД');
writeln;
if G.Number=0 then
begin
writeln('Ѓ § Ґ ᮤҐа¦Ёв Ё ®¤®© бв жЁЁ.');
readln
end
else begin
writeln('„«п ЇҐаҐ¬ҐйҐЁп Ї® бЇЁбЄг бв жЁ© ЁбЇ®«м§г©вҐ бв५ЄЁ');
writeln;
writeln(' ‘в жЁп і ‘®Ґ¤ЁҐ б');
for i:=1 to G.Number do
begin
write(' ');
WriteStr(G.Vertices[i].Name,j);
gotoxy(40,wherey);
write('і');
writeln
end; {for i}
i:=1;
gotoxy(1,6+i);
write('');
window(42,7,80,26);
ShowConnections(G,i);
window(1,1,80,43);
repeat
c:=readkey;
case c of
#72:begin {up}
if i<>1 then
begin
gotoxy(1,6+i); {бвҐаҐвм бв ал© Єгаб®а}
write(' ');
dec(i);
gotoxy(1,6+i);
write(''); {гбв ®ўЁвм ®ўл©}
window(42,7,80,26); {б®§¤ вм ®Є® ў ®ЄҐ}
ShowConnections(G,i);{ўлўҐбвЁў Ґ¬ бЇЁб®Є ᬥ¦ле бв жЁ©}
end;
end;
#80:begin {down}
if i<>G.Number then
begin
gotoxy(1,6+i);
write(' ');
inc(i);
gotoxy(1,6+i);
write('');
window(42,7,80,26);
ShowConnections(G,i);
end;
end;
end; {case}
window(1,1,80,43); {ў®ббв ®ўЁвм з «м®Ґ ®Є®}
until c=#27;
end; {else}
end;
{б®еа Ёвм ¬ аиагвл ў д ©«.}
procedure SaveRoutes(var f:text; const G:TGraph);
var s:string;
begin
clrscr;
writeln('ђҐ¦Ё¬ а Ў®вл: ¤¬ЁЁбва в®а -> б®еа ҐЁҐ а бЇЁб Ёп');
writeln('ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД');
writeln;
if G.Number=0 then
begin
writeln('ђ бЇЁб ЁҐ Їгбв®. ‘®еа ҐЁҐ Ґў®§¬®¦®.');
readln
end
else begin
writeln('‚ўҐ¤ЁвҐ Ё¬п ⥪бв®ў®Ј® д ©« (*.txt)');
readln(s);
assign(f,s);
{$I-}
rewrite(f);
{$I+}
if IOresult<>0 then writeln('‡ ЇЁбм ў д ©« "',s,'" Ґў®§¬®¦ .')
else begin
SaveGraph(f,G);
writeln('ђ бЇЁб ЁҐ б®еа Ґ®.');
readln
end;
end;
end;
{§ Јаг§Ёвм ¬ аиагвл Ё§ д ©« }
procedure LoadRoutes(var f:Text; var G:TGraph);
var s:string;
c:char;
begin
clrscr;
writeln('ђҐ¦Ё¬ а Ў®вл: ¤¬ЁЁбва в®а -> § Јаг§Є а бЇЁб Ёп');
writeln('ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД');
writeln;
writeln('‚ўҐ¤ЁвҐ Ё¬п ⥪бв®ў®Ј® д ©« (*.txt)');
readln(s);
assign(f,s);
{$I-}
reset(f);
{$I+}
if IOresult<>0 then writeln('ЌҐў®§¬®¦® ®вЄалвм д ©« "',s,'".')
else begin
if eof(f) then writeln('” ©« "',s,'" Їгбв.')
else begin
readln(f,c); {Їа®ўҐаЄ § йЁв®Ј® Ў ©в }
if c<>#0 then writeln('"',s,'" Ґ пў«пҐвбп д ©«®¬ а бЇЁб Ёп.')
else begin
LoadGraph(f,G);
writeln('ђ бЇЁб ЁҐ § Ја㦥®.');
end;
end;
readln
end;
end;
{। ЄвЁа®ў ЁҐ а бЇЁб Ёп}
procedure EditTimeTable(var G:TGraph; view:boolean);
var i,j,realj,cn:byte;
c:char;
{¤«п § ¤ ®Ј® ᮥ¤ЁҐЁп бзЁвлў вм бва®ЄЁ в Ў«Ёжл а бЇЁб Ёп}
procedure ReadTimeTableLines(var G:TGraph; Index1,Index2:byte);
var p,p1:PTimeTableElem;
t:PDestination;
R:TRoute;
err:boolean;
c:char;
s:TimeTableString;
n:byte;
label addmore, addexisting, question;
begin
n:=0;
p:=GetTimeTable(G,Index1,Index2); {гЄ § ⥫м з «® в Ў«Ёжл а бЇЁб Ёп}
p1:=p;
t:=G.Vertices[Index1].Connections;
while t^.where<>Index2 do t:=t^.NextStation;
writeln;
err:=false;
goto addmore;
addexisting: {¤®Ў ў«ҐЁҐ бгйҐбвўго饩 бва®ЄЁ}
if err then
begin
gotoxy(1,wherey-1);
clreol;
gotoxy(1,wherey-1);
clreol;
end;
gotoxy(1,wherey-1);
clreol;
if p<>nil then
begin
writeTime(p^.Route.DepTime);
write(' ');
writeTime(p^.Route.ArrTime);
write(' ');
writeln(p^.Route.price);
p1:=p;
p:=p^.next;
inc(n);
goto question;
end;
addmore:
readln(s); {бзЁв вм бва®Єг}
EncodeTimeTableLine(s,err,R); {ЇаҐ®Ўа §®ў вм ҐҐ ў бва®Єг а бЇЁб Ёп}
if not err then {Ґб«Ё Ґ ᮤҐа¦Ёв бЁв ЄбЁзҐбЄЁе ®иЁЎ®Є}
begin
inc(n);
if n<=t^.TimeTableLines then
begin
p^.Route:=r;
p1:=p;
p:=p^.Next
end
else if n<MaxLines then
begin
new(p);
p^.Route:=R;
p^.Next:=nil;
inc(t^.TimeTableLines);
if GetTimeTable(G,Index1,Index2)=nil then t^.TimeTable:=p
else p1^.Next:=p;
p1:=p;
end; {else n}
end {if not err}
else writeln('ЋиЁЎЄ ў бвагЄвгॠўўҐ¤Ґ®© бва®ЄЁ.');
question:
writeln('„®Ў ўЁвм ҐйҐ бва®Єг а бЇЁб Ёп? (Y/N).');
c:=readkey;
if (c='Y') or (c='y') then
begin
gotoxy(1,wherey-1);
clreol;
if err then
begin
gotoxy(1,wherey-1);
clreol;
gotoxy(1,wherey-1);
clreol
end;
goto addmore
end
else if (c=#9) then goto addexisting;
clrscr;
end; {proc}
begin
clrscr;
if view then begin
writeln('ђҐ¦Ё¬ а Ў®вл: ¤¬ЁЁбва в®а -> Їа®б¬®ва а бЇЁб Ёп');
writeln('ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД');
end else begin
writeln('ђҐ¦Ё¬ а Ў®вл: ¤¬ЁЁбва в®а -> । ЄвЁа®ў ЁҐ а бЇЁб Ёп');
writeln('ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД');
end;
writeln;
if G.Number=0 then
begin
writeln('Ѓ § Ґ ᮤҐа¦Ёв Ё ®¤®© бв жЁЁ.');
readln
end
else begin
writeln('„«п ЇҐаҐ¬ҐйҐЁп Ї® бЇЁбЄг бв жЁ© ЁбЇ®«м§г©вҐ <PgUp>, <PgDn>');
writeln('„«п ЇҐаҐ¬ҐйҐЁп Ї® бЇЁбЄг ᮥ¤ЁҐЁ© - бв५ЄЁ');
writeln;
writeln(' ‘в жЁп і ‘®Ґ¤ЁҐ б');
for i:=1 to G.Number do
begin
write(' ');
WriteStr(G.Vertices[i].Name,j);
gotoxy(40,wherey);
write('і');
writeln
end; {for i}
writeln('-------------------------------------------------------------------------------');
writeln;
if view then writeln(' ђ бЇЁб ЁҐ ўҐвўЁ')
else writeln(' ‘в ஥ а бЇЁб ЁҐ і Ќ®ў®Ґ а бЇЁб ЁҐ');
i:=1;
j:=1;
gotoxy(1,7+i);
write('');
window(42,8,80,7+G.Number);
cn:=ShowConnections(G,i);
if cn<>0 then
begin
gotoxy(1,1);
write('');
window(1,11+G.Number,39,43);
realj:=GetIndex(G,i,j);
ShowTimeTable(G,i,realj);
end;
window(1,1,80,43);
repeat
c:=readkey;
case c of
#73:begin {page up}
if i<>1 then
begin
gotoxy(1,7+i);
write(' ');
dec(i);
gotoxy(1,7+i);
write('');
window(42,8,80,7+G.Number);
cn:=ShowConnections(G,i);
if cn<>0 then
begin
j:=1;
gotoxy(1,j);
write('');
window(1,11+G.Number,39,43);
realj:=GetIndex(G,i,j);
ShowTimeTable(G,i,realj);
end else j:=0
end;
end;
#81:begin {page down}
if i<>G.Number then
begin
gotoxy(1,7+i);
write(' ');
inc(i);
gotoxy(1,7+i);
write('');
window(42,8,80,7+G.Number);
cn:=ShowConnections(G,i);
if cn<>0 then
begin
j:=1;
gotoxy(1,j);
write('');
window(1,11+G.Number,39,43);
realj:=GetIndex(G,i,j);
ShowTimeTable(G,i,realj);
end else j:=0
end;
end;
#72:begin {up}
if j>1 then
begin
window(42,8,80,7+G.Number);
gotoxy(1,j);
write(' ');
dec(j);
gotoxy(1,j);
write('');
window(1,11+G.Number,39,43);
realj:=GetIndex(G,i,j);
ShowTimeTable(G,i,realj);
end;
end;
#80:begin {down}
if j<>cn then
begin
window(42,8,80,7+G.Number);
gotoxy(1,j);
write(' ');
inc(j);
gotoxy(1,j);
write('');
window(1,11+G.Number,39,43);
realj:=GetIndex(G,i,j);
ShowTimeTable(G,i,realj);
end;
end;
#13:begin {enter}
if not view then if j<>0 then
begin
window(42,11+G.Number,80,43);
realj:=GetIndex(G,i,j);
ReadTimeTableLines(G,i,realj);
end;
end;
end; {case}
window(1,1,80,43);
until c=#27;
end;
end;
function SelectStation(const G:TGraph):byte;
var i,n:byte;
c:char;
begin
if G.Number=0 then
begin
writeln('Ѓ § Ґ ᮤҐа¦Ёв Ё ®¤®© бв жЁЁ.');
readln
end
else begin
for i:=1 to G.Number do
begin
write(' ');
WriteStr(G.Vertices[i].Name,n);
writeln;
end;
n:=1;
gotoxy(1,3+n);
write('');
repeat
c:=readkey;
if c=#72 then
begin
if n<>1 then
begin
gotoxy(1,3+n);
write(' ');
dec(n);
gotoxy(1,3+n);
write('');
end;
end
else if c=#80 then
begin
if n<>G.Number then
begin
gotoxy(1,3+n);
write(' ');
inc(n);
gotoxy(1,3+n);
write('');
end;
end;
until (c=#13) or (c=#27);
SelectStation:=n
end;
end;
function SelectTime:TTime;
var err:boolean;
c:TTime;
s:TimeStr;
begin
Window(1,4,80,43);
repeat
err:=false;
clrscr;
writeln('ђҐ¦Ё¬ а Ў®вл: Ї®«м§®ў ⥫м -> ўў®¤ ўаҐ¬ҐЁ ®вЇа ў«ҐЁп');
writeln('------------------------------------------------------');
writeln;
writeln('‚ўҐ¤ЁвҐ ўаҐ¬п ®вЇа ў«ҐЁп (ў д®а¬ ⥠——:ЊЊ)');
readln(s);
c:=StrToTime(s,err);
if err then
begin
writeln('ЋиЁЎЄ ! ЌҐўҐал© д®а¬ ⠢६ҐЁ.');
readln
end;
until not err;
SelectTime:=c;
Window(1,1,80,43);
end;
procedure FindShowWay(var G:TGraph; var way:TWay; vFrom, vTo:byte; DepTime:TTime; cheap:boolean);
var i:byte;
x:byte;
l:byte;
totalTime:word;
totalCost:LongInt;
notConnected:boolean;
begin
clrscr;
if vFrom=vTo then writeln('‘в жЁЁ ®вЇа ў«ҐЁп Ё ЇаЁЎлвЁп б®ўЇ ¤ ов.')
else begin
FastestWay(G,vFrom,vTo,DepTime,way,cheap,notConnected);
if notConnected then writeln('ѓа д Ґ пў«пҐвбп бўп§л¬. Џ®ЁбЄ ЇгвЁ Ґў®§¬®¦Ґ.')
else begin
if DepTime<=way[1].Time^.Route.DepTime
then TotalTime:=way[1].Time^.Route.DepTime-DepTime
else TotalTime:=1440-DepTime+way[1].Time^.Route.DepTime;
totalCost:=0;
i:=1;
writeln('‚ и § Їа®б:');
if cheap then write('‘ ¬л© ¤ҐиҐўл© Їгвм Ё§ ')
else write('‘ ¬л© Ўлбвал© Їгвм Ё§ ');
writeStr(G.Vertices[vFrom].Name,l);
write(' ў ');
writeStr(G.Vertices[vTo].Name,l);
writeln;
write('‚аҐ¬п ®вЇа ў«ҐЁп: ');
writeTime(DepTime);
writeln;
writeln;
writeln(' ЋвЄг¤ |‚६п| Љг¤ і‚६ﳑ⮨¬®бвм');
writeln('ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД');
while way[i].Station<>vTo do
begin
x:=way[i].Station;
writeStr(G.Vertices[x].Name,l);
write(' ':(MaxLength-l));
write('і');
writeTime(way[i].Time^.Route.DepTime);
write('і');
writeStr(G.Vertices[Way[i+1].Station].Name,l);
write(' ':(MaxLength-l));
write('і');
writeTime(way[i].Time^.Route.ArrTime);
write('і');
write(way[i].Time^.Route.Price:5);
writeln;
TotalCost:=TotalCost+way[i].Time^.Route.Price;
inc(i);
end;
if way[i-1].Time^.Route.ArrTime>way[1].Time^.Route.DepTime
then TotalTime:=TotalTime+way[i-1].Time^.Route.ArrTime-way[1].Time^.Route.DepTime
else TotalTime:=TotalTime+1440-way[i-1].Time^.Route.ArrTime+way[1].Time^.Route.DepTime;
writeln;
write('Џ®«®Ґ ўаҐ¬п Ї®Ґ§¤ЄЁ: ');
writeTime(totalTime);
writeln;
write('Џ®« п бв®Ё¬®бвм: ');
writeln(TotalCost);
end;
end;
readln;
end;
end.
Соседние файлы в папке Информационная система железнодорожной сети
