Есть программа по работе с БД
Вывод, добавление записи, удаление записи, сортировка и поиск
Но проблема в том, что программа не запускается, и я не могу понять почему

Написано все вроде правильно, но когда запускаю пишет "Ошибка 200. Деление на ноль"
В чем проблема?
Pascal |
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
| uses crt;
type student = record
surname, name, group: string[25];
nomz, labs, rate: integer;
end;
students = array [1..10] of student;
var mas: students;
f: file of student;
i, n: byte;
chose: char;
{=======Procedura 4teHia Faila=======}
procedure ReadF(var a: students);
var i: byte;
begin
reset(f);
for i:=1 to filesize(f) do
Read(f,a[i]);
close(f);
end;
{=======Procedura 3apici Faila=======}
procedure WriteF(var a: students);
var i: byte;
begin
rewrite(f);
for i:=1 to n do
write(f, a[i]);
close(f);
end;
{=======procedura DobaBJIeHia 3aIIici=======}
procedure Add(var a: students);
var i: byte;
surname, name, group: string[25];
nomz, labs, rate: integer;
begin
ReadF(a);
inc(n);
writeln('BBEDITE FAMILIY');
readln(a[n].surname);
writeln('BBEDITE IMA');
readln(a[n].name);
writeln('BBEDITE GPYIIY');
readln(a[n].group);
writeln('BBEDITE Homep 3a4.');
readln(a[n].nomz);
writeln('BBEDITE K-CTBO LAB');
readln(a[n].labs);
writeln('BBEDITE REITING');
readln(a[n].rate);
end;
{=======Procedura YDAJIEHIA 3aIIici=======}
procedure Delete(var a: students);
var surname: string[25];
i, k, count: byte;
begin
clrscr;
ReadF(a);
write('BBEDITE FAMIJIIY Studenta KOTOPUY BU XOTITE YDALIT');
readln(surname);
count:=0;
repeat
inc(count);
k:=0;
for i:=1 to n do
if a[i].surname=surname then
begin
k:=i;
break;
end; writeln;
if k=0 then
begin
write('3AIIiCb C TAKOI FAMILIEI HE HAIDEHA');
repeat until Keypressed;
exit;
end
else
begin
for i:=k to n-1 do
a[i]:=a[i+1];
dec(n);
write('3aIIiCb YDAJIEHA');
end;
writeF(a);
repeat until KeyPressed;
until count=n;
end; |
|
Добавлено через 16 секунд
Pascal |
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
| {=======Procedura BIBODA=======}
procedure Output(a: students);
var i: byte;
begin
clrscr;
ReadF(a);
if n=0 then
begin
writeln('FAIJI IIycT');
repeat until KeyPressed;
exit;
end;
writeln('FAMILIA IMA GRYPA NomerZa4 LABs REITING');
writeln;
for i:=1 to n do
begin
writeln(a[i].surname:5, a[i].name:5, a[i].group:5, a[i].nomz:5, a[i].labs:5, a[i].rate:5);
end;
repeat until Keypressed;
end;
{Procedura CoPTIPOBKI=======}
procedure Sort(var a: students);
var i, count: byte;
chose: char;
lip: student;
begin
clrscr;
ReadF(a);
if n=0 then
begin
write('FAIJI IIycT');
repeat until keypressed;
exit;
end;
writeln('1. Familii');
writeln('2. ImeHa');
writeln('3. Gpypi');
writeln('4. Nomer Za4.');
writeln('5. Lab poboti');
writeln('6. Reiting');
repeat
chose:=readKey;
until (chose in ['1'..'6']);
repeat
count:=0;
for i:=1 to n-1 do
if ((chose='1') and (a[i].surname>a[i+1].surname)) or
((chose='2') and (a[i].name>a[i+1].name)) or
((chose='3') and (a[i].group>a[i+1].group)) or
((chose='4') and (a[i].nomz>a[i+1].nomz)) or
((chose='5') and (a[i].labs>a[i+1].labs)) or
((chose='6') and (a[i].rate>a[i+1].rate)) then
begin
lip:=a[i];
a[i]:=a[i+1];
a[i+1]:=lip;
inc(count);
end;
until count=0;
clrscr;
write('FaiJI OTCOPTOPOBAHO');
repeat until Keypressed;
writeF(a);
end;
{=======Procedura Poicka IIo rpyIIe=======}
procedure Search(a: students);
var i: byte;
group: string[25];
begin
clrscr;
readF(a);
write('BBEDITE GRYIIIIy');
readln(group);
clrscr;
for i:=1 to n do
if a[i].group=group then
begin
writeln(a[i].surname:5, a[i].name);
writeln;
end;
repeat until keypressed;
end;
{=======IIpogramma=======}
Begin
assign(f,'data.dat');
reset(f);
if IOResult <> 0 then
begin
rewrite(f);
end;
n:=filesize(f);
close(f);
repeat
clrscr;
writeln('1. BIBOD BAZI');
writeln('2. DOBABITb 3AIIiCb');
writeln('3. YDAJIiTb 3AIIiCb');
writeln('4. COPTIPOBKA');
writeln('5. IIOICK CTUDEHTA');
writeln('6. BIXOD');
repeat
chose:=readkey;
until (chose in ['1'..'6']);
case chose of
'1': Output(mas);
'2': Add(mas);
'3': Delete(mas);
'4': Sort(mas);
'5': Search(mas);
end;
until chose='6';
end. |
|