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
| program MARSH;
uses crt;
type
MARSH = record
nachmarsh, konmarsh: string;
numbmarsh: integer;
end;
var
f1, f2: text;
inf:char;
procedure zapolnenie (var f:text);
const
N=10;
var
m: MARSH;
i: integer;
begin
writeln('Zapolnite informatsiyu o marshrutah:');
assign(f, 't1.txt');
rewrite(f);
for i:=1 to N do begin
with m do begin
write('Nachalniy punkt marshruta: ');
readln(nachmarsh);
write('Konechniy punkt marshruta: ');
readln(konmarsh);
write('Nomer marshruta: ');
readln(numbmarsh);
writeln(f, nachmarsh);
writeln(f, konmarsh);
writeln(f, numbmarsh);
end;
end;
writeln('Informatsia o marshrutah zapisana i sohranena.');
close(f);
end;
procedure prosmotr(var f: text);
var
n: integer;
m: MARSH;
begin
assign(f, 't1.txt');
reset(f);
writeln('Prosmotr informtsii o marshrutah');
while not eof(f) do begin
with m do begin
readln(f, nachmarsh);
readln(f, konmarsh);
readln(f, numbmarsh);
writeln('Marshrut nomer ', numbmarsh);
writeln('Punkt otprvleniya: ', nachmarsh);
writeln('Punkt pribitiya: ', konmarsh);
end;
end;
writeln('Bolshe informatsii net.');
close(f);
end;
procedure redakt(var f:text);
const N=10;
var
i:integer;
m:MARSH;
begin
writeln('Izmenenie svedeniy o marshrutah.');
assign(f, 't1.txt');
rewrite(f);
for i:=1 to N do begin
with m do begin
write('Nachalniy punkt marshruta');
readln(nachmarsh);
write('Konechniy punkt marshruta');
readln(konmarsh);
write('Nomer marshruta');
readln(numbmarsh);
writeln(f, nachmarsh);
writeln(f, konmarsh);
writeln(f, numbmarsh);
end;
end;
writeln('Izmeneniya sohraneni.');
close(f);
end;
procedure addmarsh (var f: text);
const
N=10;
var
m:MARSH;
i,j,k:integer;
begin
writeln('Dobavlenie novih marshrutov.');
assign(f, 't1.txt');
append(f);
writeln('Skolko marshrutov neobhodimo dobavit?');
readln(k);
for i:=1 to k do begin
with m do begin
write('Nachalniy punkt marshruta');
readln(nachmarsh);
write('Konechniy punkt marshruta');
readln(konmarsh);
write('Nomer marshruta');
readln(numbmarsh);
writeln(f, nachmarsh);
writeln(f, konmarsh);
writeln(f, numbmarsh);
end;
end;
writeln('Marshruti dobavleni.');
close(f);
end;
procedure searchmarsh (var f: text);
var
punkt:string;
m:MARSH;
j: integer;
begin
writeln('Vvedite nazvanie punkta marshruta.');
readln(punkt);
j:=0;
assign(f, 't1.txt');
reset(f);
while not eof(f) do begin
readln(f, m.nachmarsh);
readln(f, m.konmarsh);
readln(f, m.numbmarsh);
if ((punkt)=(m.nachmarsh)) or ((punkt)=(m.konmarsh)) then begin
j:=1;
writeln(m.nachmarsh);
writeln(m.konmarsh);
writeln(m.numbmarsh);
end;
end;
if j=0 then writeln('Marshruti otsutstvuyut.');
end;
procedure zapis (var f:text; var f2:text);
var
q:integer;
s:string;
m:MARSH;
begin
writeln('Zapis v otdelniy fail zadannogo polya.');
assign(f2, 't2.txt');
rewrite(f2);
writeln('Kakoepole zapisat?: ');
readln(s);
reset(f);
while not eof(f1) do begin
with m do begin
readln(f, nachmarsh);
readln(f, konmarsh);
readln(f, numbmarsh);
inc(q);
writeln(f2, q);
case s of
'Nachalo marshruta: ': writeln(f2, nachmarsh);
'Konec marshruta: ': writeln(f2, konmarsh);
'Nomer marshruta: ': writeln(f2, numbmarsh);
end;
end;
writeln('File zapisan.')
end;
BEGIN
clrscr;
zapolnenie(f1);
writeln('Dlya prosmotra informatsii o marshrutah nazhmite ENTER.');
readkey;
prosmotr(f1);
writeln('Zhelaete izmenit informatsiu o marshrutah?(Y/N)');
read(inf);
if inf='Y' then redakt(f1) else writeln('Zhelaete dobavit eshe marshruti?');
read(inf);
if inf='Y' then addmarsh(f1) else writeln('Poisk marshruta.');
searchmarsh(f1);
close(f1);
zapis(f1,f2);
readkey;
end. |