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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
| program kursovaya;
uses crt;
type tinf=record
marka,model,matr,displ,ves,obj,nosit,svjaz,format,cena:string;
end;
list=^Tlist;
Tlist=record
data:Tinf;
next:List;
end;
var znom:tinf;
zn:string;
spis:list;
str:string;
i,j:integer;
ch:char;
f,g:text;
h:file of char;
procedure addelem(var spis1:list;znom1:Tinf);
var tmp:list;
begin
if spis1=nil then
begin
getmem(spis1,sizeof(Tlist));
tmp:=spis1;
end
else
begin
tmp:=spis1;
while tmp^.next<>nil do
tmp:=tmp^.next;
getmem(tmp^.next,sizeof(tlist));
tmp:=tmp^.next;
end;
tmp^.next:=nil;
tmp^.data:=znom1;
end;
procedure files(var spis1:list);
var tmp:list;
begin
if spis1=nil then begin writeln('Список пуст');
exit;
end
else
tmp:=spis1;
while tmp<>nil do
begin
writeln(g,tmp^.data.marka,' ',tmp^.data.model,' ',tmp^.data.matr,' ',tmp^.data.displ,' ',
tmp^.data.ves,' ',tmp^.data.obj,' ',tmp^.data.nosit,' ',tmp^.data.svjaz,' ',
tmp^.data.format,' ',tmp^.data.cena);
tmp:=tmp^.next;
end;
end;
procedure vivod(spis1:list);
begin
writeln;
if spis1=nil then
begin
writeln('Список пуст');
exit;
end;
writeln('---------------------------------------------------------------------------------------------------------------------- ');
writeln('Марка|Модель| Матрица|Дисплей|Вес |Вспышка|Носитель|Связь|Формат|Цена|');
while spis1<>nil do
begin
begin
gotoxy(1,whereY);write('|’,spis1^.data.marka);
gotoxY(9,whereY);write('|’,spis1^.data.model);
gotoxy(18,whereY);write('|’,spis1^.data.matr);
gotoxy(26,whereY);write('|’,spis1^.data.displ);
gotoxy(34,wherey);write('|’,spis1^.data.ves);
gotoxy(39,wherey);write('|’,spis1^.data.obj);
gotoxy(48,wherey);write('|’,spis1^.data.nosit);
gotoxy(58,wherey);write('|’,spis1^.data.svjaz);
gotoxy(65,wherey);write('|’,spis1^.data.format);
gotoxy(73,wherey);write('|’,spis1^.data.cena);
gotoxy(80,whereY);writeln('|');
end;
spis1:=spis1^.next;
end;
writeln;
end;
procedure freestek(spis1:list);
var tmp:list;
begin
while spis<>nil do
begin
tmp:=spis1;
spis1:=spis1^.next;
freemem(tmp,sizeof(tlist));
end;
end;
procedure poisk(spis1:list;znom1:string);
begin
while (spis1<>nil) do
begin
if spis1^.data.marka=znom1 then
writeln(spis1^.data.marka,' ',spis1^.data.model,' ',spis1^.data.matr,' ',spis1^.data.displ,' ',spis1^.data.ves,' ',
spis1^.data.obj,' ',spis1^.data.nosit,' ',spis1^.data.svjaz,' ',spis1^.data.format,' ',spis1^.data.cena);
spis1:=spis^.next;
end;
writeln;
end;
procedure delelem(var spis1:list;tmp:list);
var tmpi:list;
begin
if (spis1=nil) or (tmp=nil) then exit;
if tmp=spis1 then
begin
spis1:=tmp^.next;
freemem(tmp,sizeof(tlist));
end
else
begin
tmpi:=spis1;
while tmpi^.next<>tmp do
tmpi:=tmpi^.next;
tmpi^.next:=tmp^.next;
freemem(tmp, sizeof(tlist));
end;
end;
procedure delete(var spis1:list;posi:integer);
var i:integer; tmp:list;
begin
if posi<1 then
exit;
if spis1=nil then
begin
writeln('Список пуст');
exit
end;
i:=1;
tmp:=spis1;
while (tmp<>nil) and (i<>posi) do
begin
tmp:=tmp^.next;
inc(i)
end;
delelem(spis1,tmp);
end;
procedure sortirovka(nom:list);
var tmp,rab:list;
tmps:tinf;
begin
getmem(tmp,sizeof(tlist));
rab:=nom;
while rab<>nil do
begin
tmp:=rab^.next;
while tmp<>nil do
begin
if tmp^.data.marka<rab^.data.marka then
begin
tmps:=tmp^.data;
tmp^.data:=rab^.data;
rab^.data:=tmps;
end;
tmp:=tmp^.next
end;
rab:=rab^.next
end;
end;
procedure redmodel(var spis1:list;posi:integer);
var i:integer;
tmp:list;
st:string;
begin
if posi<1 then
exit;
if spis1=nil then
begin
write('Список пуст');
end;
i:=1;
tmp:=spis1;
while (tmp<>nil) and (i<>posi) do
begin
tmp:=tmp^.next;
inc(i);
end;
writeln('Введите модель');
readln(st);
tmp^.data.model:=st;
end;
procedure redmatr(var spis1:list; posi:integer);
var i:integer;
tmp:list;
st:string;
begin
if posi<1 then
exit;
if spis1=nil then
begin
write('Список пуст');
end;
i:=1;
tmp:=spis1;
while (tmp<>nil) and (i<>posi) do
begin
tmp:=tmp^.next;
inc(i);
end;
writeln('Введите параметры матрицы’);
readln(st);
tmp^.data.matr:=st;
end;
procedure reddispl(var spis1:list;posi:integer);
var i:integer;
tmp:list;
st:string;
begin
if posi<1 then
exit;
if spis1=nil then
begin
write('Список пуст');
end;
i:=1;
tmp:=spis1;
while (tmp<>nil) and (i<>posi) do
begin
tmp:=tmp^.next;
inc(i);
end;
writeln(‘Введите параметры дисплея’);
readln(st);
tmp^.data.displ:=st;
end;
procedure redmarka(var spis1:list;posi:integer);
var i:integer;
tmp:list;
st:string;
begin
if posi<1 then
exit;
if spis1=nil then
begin
write(‘Список пуст');
end;
i:=1;
tmp:=spis1;
while (tmp<>nil) and (i<>posi) do
begin
tmp:=tmp^.next;
inc(i);
end;
writeln('Введите марку');
readln(st);
tmp^.data.marka:=st;
end;
procedure redves(var spis1:list;posi:integer);
var i:integer;
tmp:list;
st:string;
begin
if posi<1 then exit;
if spis1=nil then
begin
write('懐ㄡ 徕');
end;
i:=1;
tmp:=spis1;
while(tmp<>nil) and (i<>posi) do
begin
tmp:=tmp^.next;
inc(i);
end;
writeln('偄イㄢ?ⅴ?');
readln(st);
tmp^.data.ves:=st;
end;
procedure redobj(var spis1:list;posi:integer);
var i:integer;
tmp:list;
st:string;
begin
if posi<1 then exit;
if spis1=nil then
begin
write('懐ㄡ 徕');
end;
i:=1;
tmp:=spis1;
while (tmp<>nil) and (i<>posi) do
begin
tmp:=tmp^.next;
inc(i);
end;
writeln('偄イㄢ?瓲绋?⑨瑾?');
readln(st);
tmp^.data.obj:=st;
end;
procedure rednosit(var spis1:list;posi:integer);
var i:integer;
tmp:list;
st:string;
begin
if posi<1 then exit;
if spis1=nil then
begin
write('懐ㄡ 徕');
end;
i:=1;
tmp:=spis1;
while (tmp<>nil) and (i<>posi) do
begin
tmp:=tmp^.next;
inc(i);
end;
writeln('偄イㄢ?猕?屺猊:');
readln(st);
tmp^.data.obj:=st;
end;
procedure redsvjaz(var spis1:list;posi:integer);
var i:integer;
tmp:list;
st:string;
begin
if posi<1 then exit;
if spis1=nil then
begin
write('懐ㄡ 徕');
end;
i:=1;
tmp:=spis1;
while (tmp<>nil) and (i<>posi) do
begin
tmp:=tmp^.next;
inc(i);
end;
writeln('偄イㄢ?猕?幄铵??む. 汜忄徕:');
readln(st);
tmp^.data.svjaz:=st;
end;
procedure redformat(var spis1:list;posi:integer);
var i:integer;
tmp:list;
st:string;
begin
if posi<1 then exit;
if spis1=nil then
begin
write('懐ㄡ 徕');
end;
i:=1;
tmp:=spis1;
while (tmp<>nil) and (i<>posi) do
begin
tmp:=tmp^.next;
inc(i);
end;
writeln('偄イㄢ?ぎ徕惘?洚喱犫 岘ì?');
readln(st);
tmp^.data.format:=st;
end;
procedure redcena(var spis1:list;posi:integer);
var i:integer;
tmp:list;
st:string;
begin
if posi<1 then exit;
if spis1=nil then
begin
write('懐ㄡ 徕');
end;
i:=1;
tmp:=spis1;
while (tmp<>nil) and (i<>posi) do
begin
tmp:=tmp^.next;
inc(i);
end;
writeln('偄イㄢ?妤:');
readln(st);
tmp^.data.cena:=st;
end;
begin
spis:=nil;
clrscr;
assign(f,'C:\files.txt');
reset(f);
while not eof(f) do begin
readln(f,str);
znom.marka:=copy(str,1,6);
znom.model:=copy(str,8,4);
znom.matr:=copy(str,14,5);
znom.displ:=copy(str,19,2);
addelem(spis,znom);
end;
repeat
writeln('1-劗キē 慝ガキ鉅');
writeln('2-傠?);
writeln('3-懏噔ㄠ獱');
writeln('4-clrscr');
writeln('5-彯ㄡ?);
writeln('6-摛牜キē');
writeln('7-惀ㄠ牠ē');
writeln('8-嚑釥忪 ?錉┇');
writeln('9-椻キē ě 錉┇?);
writeln('0-傠瀹?);
readln(ch);
case ch of
'1':begin
writeln('偄イㄢ?瑺嗒?');
readln(znom.marka);
writeln('偄イㄢ?ぅ:');
readln(znom.model);
writeln('偄イㄢ?癄酄忄?瑺忄ㄦ?');
readln(znom.matr);
writeln('偄イㄢ?癄酄忄?え岑?');
readln(znom.displ);
writeln('偄イㄢ?ⅴ?');
readln(znom.ves);
writeln('偄イㄢ?瓲绋?⑨瑾?');
readln(znom.obj);
writeln('偄イㄢ?猕?屺猊:');
readln(znom.nosit);
writeln('偄イㄢ?猕?幄铵??む.汜忄徕:');
readln(znom.svjaz);
writeln('偄イㄢ?ぎ徕惘?洚喱犫 岘ì?');
readln(znom.format);
writeln('偄イㄢ?妤:');
readln(znom.cena);
addelem(spis,znom);
end;
'2':begin
clrscr;
vivod(spis);
end;
'3':begin
sortirovka(spis);
end;
'4':begin clrscr;
end;
'5':begin
if spis=nil then
writeln('懐ㄡ 徕')
else
begin
writeln('偄イㄢ?瑺嗒?);
readln(str);
poisk(spis,str);
end;
end;
'6':begin
writeln('偄イㄢ??慝ガキ鉅, 猱嚯?瓲ぎ 悚牜ㄢ?);
readln(i);
writeln('椻?㈦ 瀹猕猊 啷ㄠ犫?',
' 1-尃嗒?2-尞ぅ,3-尃忄ㄦ?4-劏岑?5-偉?6-傖瑾?7-嵁屺猊,8-憿铵?9-敭喱犫,10-枼瓲');
readln(j);
case j of
1:begin
redmarka(spis,i);
end;
2:begin redmodel(spis,i);end;
3:begin redmatr(spis,i);end;
4:begin reddispl(spis,i);end;
5:begin redves(spis,i);end;
6:begin redobj(spis,i);end;
7:begin rednosit(spis,i);end;
8:begin redsvjaz(spis,i);end;
9:begin redformat(spis,i);end;
10:begin redcena(spis,i);end;
end;
end;
'7':begin
writeln('偄イㄢ??慝ガキ鉅, 猱嚯?瀹猕猊 啷ㄠ犫?);
readln(i);
writeln('椻?㈦ 瀹猕猊 啷ㄠ犫?',
' 1-尃嗒?2-尞ぅ,3-尃忄ㄦ?4-劏岑?5-偉?6-傖瑾?7-嵁屺猊,8-憿铵?9-敭喱犫,10-枼瓲');
readln(j);
case j of
1:begin
redmarka(spis,i);
end;
2:begin redmodel(spis,i);end;
3:begin redmatr(spis,i);end;
4:begin reddispl(spis,i);end;
5:begin redves(spis,i);end;
6:begin redobj(spis,i);end;
7:begin rednosit(spis,i);end;
8:begin redsvjaz(spis,i);end;
9:begin redformat(spis,i);end;
10:begin redcena(spis,i);end;
end;
end;
'8':begin
assign(g,'C:\file2.txt');
rewrite(g);
files(spis);
close(g);
end;
'9':begin
assign(g,'C:\file2.txt');
reset(g);
while not eof(g) do
begin
readln(g,str);
znom.marka:=copy(str,1,6);
znom.model:=copy(str,7,9);
znom.matr:=copy(str,15,4);
znom.displ:=copy(str,20,4);
znom.ves:=copy(str,24,3);
znom.obj:=copy(str,28,4);
znom.nosit:=copy(str,33,7);
znom.svjaz:=copy(str,41,7);
znom.format:=copy(str,49,4);
znom.cena:=copy(str,53,6);
addelem(spis,znom);
end;
end;
end;
until ch='0';
close(f);
freestek(spis);spis:=nil;
end. |