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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
| Program Sanjik;
uses crt;
type napitki=record
nom:byte;
nazv:string[20];
sahar:integer;
kol:integer;
cen:longint;
str:string[30];
end;
var w,l:integer; p:napitki;
f,f1:file of napitki;
tnapitki,a,b:array [1..50] of napitki;
procedure WriteFile;
var a:napitki;
n:byte;
c:char;
begin
assign(f,'f:\napitki.dat');
rewrite(f);
writeln('Vvedite dannie o napitkah');
n:=0;
repeat
n:=n+1;
with a do
begin
nom:=n;
write('nazvanie napitka: ');readln(nazv);
repeat
write(' kol-vo sahara(10-200): ');readln(sahar);
until (sahar>9)and(sahar<200);
write(' Kolichestvo: ');readln(kol);
write(' Cena: ');readln(cen);
Write(' Strana: ');Readln(str);
write(f,a);
writeln('dlya prodolzhenia nazhmite klavishu "ENTER"'); {readln;}
end;
c:=readkey;
until c=#27;
clrscr;
close(f);
end;
procedure ReadFile;
var a:napitki; o:string; m:longint;
begin
writeln('ukazhite put prosmatrivaemogo faila:'); readln(o);
assign(f,o);
reset(f);
textcolor(green);
writeln('Spisok napitkov v magazine adal:':35);
writeln; textcolor(green);
writeln('----------------------------------------------------------------------');
writeln('| Pn | nazvanie | sahar | Kol-vo | Cena | Strana | obs st |');
writeln('----------------------------------------------------------------------');
while not eof(f) do
begin
read(f,a);
with a do
begin
m:=kol*cen;
gotoXY(1,whereY);write('|',nom:3);
gotoXY(6,whereY);write('| ',nazv);
gotoXY(19,whereY);write('| ',sahar);
gotoXY(27,whereY);write('|',kol:6);
gotoXY(36,whereY);write('| ',cen:5);
gotoXY(47,whereY);write('| ',str);
gotoXY(60,whereY);write('| ',m:5);
gotoXY(70,whereY);writeln('| ');
end;
end;
writeln('------------------------------------------------------------------------');
close(f);
writeln('dlya prodolzhenia nazhmite klavishu "ENTER"');
readln;
end;
procedure FindMaks;{samaya visokoe kol-vo sahara}
var v,r:napitki;
begin
assign(f,'f:\napitki.dat');
reset(f);
r.sahar:=-1;
while not (eof(f)) do
begin
read (f,v);
if v.sahar>r.sahar then r:=v;
end;
writeln('samoe visokoe kol-vo sahara : ',r.sahar,' Strana proizvoditel: ',r.str); readln;
close(f);
end;
Procedure FindMax1;{napitkov kol-vo kotorogo bolshe vsego}
Var v,r:napitki;
begin
Assign(f,'F:\napitki.dat');
ReSet(F);
r.kol:=-1;
While Not(EOF(F)) do
begin
Read(F,v);
if v.kol>r.kol then r:=v;
end;
Writeln('Samoe visokoe kol-vo napitkov: ',r.kol,' Strana proizvoditel: ',r.str ); Readln;
Close(F);
end;
procedure sort;{sortirovka po nazvaniu napitka ot a do z}
var i,j,q:integer;
t:napitki;
begin
assign(f,'f:\napitki.dat'); assign(f1,'f:\napitki1.dat');
reset(f);rewrite(f1);
i:=1;
while not (eof(f)) do begin
read(f,tnapitki[i]); i:=i+1; end; q:=i;
for i:=1 to q-2 do
for j:=i+1 to q-1 do
if tnapitki[i].nazv>tnapitki[j].nazv then begin
t:=tnapitki[i]; tnapitki[i]:=tnapitki[j]; tnapitki[j]:=t; end;
for i:=1 to q-1 do begin
write(f1,tnapitki[i]);
end; writeln('spisok osortirovan no nazvaniu!');
writeln('dlya prodolzhenia nazhmite ENTER'); close(f); close(f1); readln;
end;
procedure dobavlenie;{dobavlenie dannih}
var c:char; k,i,j,n:integer;
label dob;
begin
assign(f,'f:\napitki.dat');
reset(f);
repeat
writeln('Vi hotite dobavit dannie?(Y/N)');
c:=readkey;
if c=#110 then goto dob;
until c=#121;
k:=0;
repeat
inc(k);
read(f,A[k]);
until eof(f);
clrscr;
i:=0;
repeat inc(i);
textcolor(green);
n:=0;
repeat
n:=n+1;
writeln('nomer:');
readln(p.nom);
writeln('nazvanie:');
readln(p.nazv);
writeln('kol-vo sahara(10-200):'); readln(p.sahar);
until(p.sahar>9) and (p.sahar<201);
writeln('kolichestvo:');
readln(p.kol);
write('cena:');
readln(p.cen);
write('strana:');
readln(p.str);
A[K+i]:=p;
n:=i;
writeln('esli vi zakonchili nazhmite ESC');
writeln;
c:=readkey
until c=#27;
for i:=k+1 to k+n do
write(f,A[i]);
close(f);
dob:
end;
Procedure Redakt;{Redaktirovanie dannih}
Var c:Char; k,i:Integer;
Label Red;
Var s:string;
Begin
Assign(F, 'f:\napitki.dat');
Reset(F);
Repeat
Writeln('Vi hotite otredaktirovat dannie? (Y/N)');
c:=readkey;
If c=#110 then goto Red;
Until c=#121;
k:=0;
Repeat
Inc(k);
Read(F, A[k]);
Until EOF(F);
Clrscr;
Writeln('Kakyu zapis vi hotite otredaktirovat?');
Readln(i);
Repeat
Writeln('Vvedite to,chto hotite otredaktirovat:'); Writeln;
Write('pn,napitok,kant,sanasi,aksa,memleket,');
Writeln;
Readln(s);
Textcolor(2);
if s='pn' then begin
Readln(p.nom);
A[i].nom:=p.nom;
end;
if s='napitok' then begin
Readln(p.nazv);
A[i].nazv:=p.nazv;
end;
if s='kant' then begin
Readln(p.sahar);
If (p.sahar>9)and(p.sahar<200) then
A[i].sahar:=p.sahar;
end;
if s='sanasi' then begin
Readln(p.kol);
A[i].kol:=p.kol;
end;
if s='aksa' then begin
Readln(p.cen);
A[i].cen:=p.cen;
end;
if s='memleket' then begin
Readln(p.str);
A[i].str:=p.str;
end;
TextColor(14);
Writeln;
Writeln('Esli vi zakonchili nazhmite "Esc"');
c:=readkey;
Until c=#27;
Close(f);
Rewrite(f);
For i:=1 to k do
Write(F, A[i]);
Close(F);
Red:
end;
Procedure Delete; {Ydalenie Redaktirovanie}
Var c:Char; k,i,n:Integer;
Label Del;
Begin
Assign(F, 'f:\napitki.dat');
Reset(F);
Repeat
Writeln('Vi hotite ydalit dannie? (Y/N)');
c:=readkey;
If c=#110 then goto Del;
Until c=#121;
k :=0;
Repeat
Inc(k);
Read(F, A[k]);
Until EOF(F);
ClrScr;
Writeln('Kakyu zapis vi hotite ydalit?');
Readln(i);
Close(f);
Rewrite(f);
n:=0;
While n<>k do begin
Inc(n);
if i<>a[n].nom then
Write(F, A[n]);
End;
Writeln('Zapis ydalena!');
Close(F);
ReadLn;
Del:
end;
begin
l:=1;
while l<>0 do begin
clrscr;
writeln('Vibor');
writeln('1-sozdanie novogo faila');
writeln('2-prosmotr sushestvueshego faila');
writeln('3-vivod strani v kotorom soderzhitsia max kol-vo sahara');
writeln('4-sortirovka spiska po nazvaniu');
writeln('5-dobavlenie novoi zapisi v sushestvuishii fail');
writeln('6-redaktirovanie zapisei');
writeln('7-udalenie zapisi');
writeln('8-vivod strani kotorii poroizvodit samoe maximalnoe kol-vo napitkov');
writeln('9-Vihod iz samoi krutoi programmi');
readln(w);
case w of
1:writefile;
2:readfile;
3:findmaks;
4:sort;
5:dobavlenie;
6:redakt;
7:delete;
8:findmax1;
9:l:=0;
end;
end;
end. |