1 / 1 / 1
Регистрация: 23.09.2015
Сообщений: 106
|
|
1
|
Посмотрите код. Почему выдает ошибку?
04.11.2016, 13:11. Показов 666. Ответов 2
Как исправить ошибку? Помогите пожалуйста
Задача:
Авиабилет
Структура записи
-пункт назначения
- номер рейса
- модель самолета
- ФИО пассажира
- Дата вылета:
-день
-месяц
- год
Записи упорядоченный по пункту назначения . Определить пункт назначения , в который вылетает наибольшее кол-во пассажиров
Тут выдает ошибку
Delphi | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| begin
if count > max_count then
begin
max_count := count;
result := cur_pnkt;
end;
//подготовка к работе в след.группе
count := 1
cur_pnkt=p^.info.pnkt;
p:=p^.next;
end; |
|
Delphi | 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
| program Project1;
uses
SysUtils,
Un_list in 'Un_list.pas',
Windows,
Un_Aviabilet in 'Un_Aviabilet.pas',
Un_Airport in 'Un_Airport.pas';
var
F:TAirport;
result_pnkt:string;
function Cours_max_Exellent(F: TAirport): string;
var
p: Tlist;
cur_pnkt: string;
count, max_count: integer;
begin
p := F.list^.next;
cur_pnkt := p^.info.pnkt;
count := 0;
max_count := 0;
while p <> nil do
begin
if p^.info.pnkt = cur_pnkt then
begin
inc(count);
end
else
begin
if count > max_count then
begin
max_count := count;
result := cur_pnkt;
end;
//подготовка к работе в след.группе
count := 1
cur_pnkt=p^.info.pnkt;
p:=p^.next;
end;
//анализ работы в последней группе
if count > max_count then
begin
max_count := count;
result := cur_pnkt;
end;
//главная программа
begin
setConsoleOutputCP(1251);
SetConsoleCP(1251);
Create(f, 'aviabilet.txt');
Print(f);
result_pnkt:= cours_max_Exellent(F);
writeln('Пункт, result_pnkt);
Print(F);
Clear(F);
readln;
end;
end;
end;
end. |
|
Delphi | 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
| unit Un_list;
interface
uses Un_Aviabilet;
type
TInfo = integer;
Tlist = ^Node;
Node = record
info: TAviabilet;
next: Tlist;
end;
procedure Create(var L: TList; var f: TextFile);
procedure Print_to_screen(L: Tlist);
procedure Clear(var L: Tlist);
function Del_After_Node(var Pnode: TList): TAviabilet;
implementation
procedure Init(var L: Tlist);
begin
new(L);
L^.next := nil;
end;
function Empty(L: TList): boolean;
begin
result := L^.next = nil;
end;
procedure Add_after_Node(var PNode: TList; new_elem: TAviabilet);
var
p: TList;
begin
new(p);
p^.info := new_elem;
p^.next := PNode^.next;
Pnode^.next := p;
end;
function Del_After_Node(var Pnode: TList): TAviabilet;
var
p: TList;
begin
p := PNode^.next;
PNode^.next := p^.next;
result := p^.info;
p^.next := nil;
dispose(p);
end;
function Found_Place(L: TList; new_elem: TAviabilet): TList;
begin
result := L;
while(result^.next <> nil) and (compare(result^.next^.info, new_elem) < 0) do
result := result^.next;
end;
procedure Create(var L: TList; var f: TextFile);
var
new_elem: TAviabilet;
place: TList;
begin
Init(L);
while not eof(f) do
begin
readST(f, new_elem);
place := Found_place(L, new_elem);
Add_after_Node(Place, new_elem);
end;
CloseFile(f);
end;
procedure Print_to_screen(L: TList);
var
p: TList;
f: Textfile;
begin
p := L^.next;
while p <> nil do
begin
WriteSt(p^.info);
p := p^.next;
end;
end;
procedure Clear(var L: Tlist);
begin
while not Empty(L) do
Del_after_Node(L);
dispose(L);
end;
end. |
|
Delphi | 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
| unit Un_Aviabilet;
interface
Type
Tdate=record
day:byte;
month:byte;
year:byte;
end;
TAviabilet=record
pnkt: string;
nmbr: integer;
model:string;
FIO:string;
date: Tdate;
end;
Procedure ReadSt(var St:TAviabilet); overload;
Procedure ReadSt(var t:TextFile; var St:TAviabilet); overload;
Procedure WriteSt(St:TAviabilet);
Function Compare (St1,St2:TAviabilet):integer;// -1; St1<St2
// 0; St1=St2
// 1; St1>St2
implementation
Procedure ReadSt(var St:TAviabilet);
begin
Write('Пункт назначения: ');
Readln(St.pnkt);
Write('Номер рейса: ');
Readln(St.nmbr);
Write('Ф.И.О: ');
Readln(St.FIO);
Write('Дата вылета: ');
Write('День');
readln(St.date.day);
Write('Месяц');
readln(St.date.month);
Write('Год');
readln(St.date.year);
readln;
end;
Procedure ReadSt(var t:TextFile; var St:TAviabilet);
begin
Write('Пункт назначения: ');
Readln(St.pnkt);
Write('Номер рейса: ');
Readln(St.nmbr);
Write('Ф.И.О: ');
Readln(St.FIO);
Write('Дата вылета: ');
Readln(St.date.day, St.date.month, St.date.year);
readln;
readln(T);
if not eof(t) then readln(T);//пропуск строки разделителя
end;
Procedure WriteSt(St:TAviabilet);
begin
Writeln('Пункт назначение: ', St.pnkt);
Writeln('Номер рейса : ', St.nmbr);
Writeln('Пассажир: ', St.FIO);
Write('Дата вылета: ');
Write('День:',St.date.day);
Write('Месяц:',St.date.month);
Write('Год:', St.date.year);
readln;
end;
Function Compare (St1,St2:TAviabilet):integer;// -1; St1<St2
// 0; St1=St2
// 1; St1>St2
begin
if (St1.pnkt <St2.pnkt) then
result:=-1
else
if (St1.pnkt=St2.pnkt) then
result:=0
else
result:=1;
end;
end. |
|
Delphi | 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
| unit Un_Airport;
interface
uses Un_list;
Type TAirport=record
name:string;
list:Tlist;
end;
Procedure Create (var F:TAirport;file_name:string);
Procedure Print (F:TAirport);
procedure Clear (F:TAirport);
implementation
Procedure Create (var F:TAirport;file_name:string);
var
t:textFile;
begin
AssignFile(t,file_name);
Reset(t);
Readln(t,F.name);
Un_list.Create(F.list,t);
end;
Procedure Print (F:TAirport);
begin
Writeln('Аэропорт:', F.name);
Writeln('---------------------');
Print_to_screen(F.list);
end;
procedure Clear (F:TAirport);
begin
Un_list.Clear(F.list);
end;
end. |
|
0
|