0 / 0 / 0
Регистрация: 10.12.2017
Сообщений: 1
1

Встречено 'end', а ожидалось begin

10.12.2017, 15:45. Показов 1142. Ответов 1

Студворк — интернет-сервис помощи студентам
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
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
uses Crt;
 
Const
    MaxRec = 4;
Type
    String11 = String[11];
    String25 = String[25];
    TStudent = record
     Number := String;
     FirstName,
     MiddleName,
     LastName: String25;
    end;
    TSortField = (sfNumber, sfFirstName, sfMiddleName);
    TCourse = object;
     Count = Integer;
     Students = Array[1..MaxRec] of TStudent;
     constructor Init;
     procedure Add(Number: String11; FirstName, MiddleName, LastName: String25);
     procedure Del(Number: String11);
     procedure Sort(SortField: TSortField);
     procedure Print(Title: String);
     procedure Save;
     procedure Load;
    
 
    constructor TCourse.Init;
    begin
     Self.Count := 0;
    end;
 
    procedure TCourse.Add(Number: String11; FirstName, MiddleName, LastName: String25);
    begin
     if Count + 1 > MaxRec then Exit;
     Inc(Count);
     Students[Count].Number := Number;
     Students[Count].FirstName := FirstName;
     Students[Count].MiddleName := MiddleName;
     Students[Count].LastName := LastName;
    end;
 
    procedure TCourse.Del(Number: String11);
    var i,j: Integer;
    begin
     for i := 1 to Count
     do if Students[i].Number = Number
        then begin
             for j := i to Count - 1
             do Students[j] := Students[j+1];
             Dec(Count);
             end;
    end;
 
    procedure TCourse.Sort(SortField: TSortField);
     procedure Exchange(var Rec1, Rec2: TStudent);
     var Tmp: TStudent;
     begin
      Tmp := Rec1;
      Rec1 := Rec2;
      Rec2 := Tmp;
     end;
    var i,j: Integer;
    begin
     for i := 1 to Count
     do for j := i+1 to Count
        do case SortField
           of sfNumber:
              if Students[j].Number < Students[i].Number
              then Exchange(Students[j], Students[i]);
              sfFirstName:
              if Students[j].FirstName < Students[i].FirstName
              then Exchange(Students[j], Students[i]);
              sfMiddleName:
              if Students[j].MiddleName < Students[i].MiddleName
              then Exchange(Students[j], Students[i]);
           end;
    end;
 
    procedure TCourse.Print(Title: String);
    var i: Integer;
    begin
     WriteLn(Title);
     for i := 1 to Count
     do with Students[i]
        do WriteLn(Number,' ',FirstName,' ',MiddleName,' ',LastName);
    end;
 
    procedure TCourse.Save;
    var
       F: File of TStudent;
       i: Integer;
    begin
     Assign(F, 'Student.dat');
     Rewrite(F);
     for i := 1 to Count
     do Write(F, Students[i]);
     Close(F);
    end;
 
    procedure TCourse.Load;
    var
       F: File of TStudent;
       i: Integer;
       Rec: TStudent;
    begin
     Init;
     Assign(F, 'Student.dat');
     Reset(F);
     while not Eof(F)
     do begin
        Read(F, Rec);
        Add(Rec.Number,Rec.FirstName,Rec.MiddleName,Rec.LastName);
        end;
     Close(F);
    end;
 
var
   Course: TCourse;
begin
 ClrScr;
 Course.Init;
 Course.Add('1','Иванов','Степан','Сергеевич');
 Course.Add('2','Петров','Никита','Александрович');
 Course.Add('3','Сидоров','Алексей','Сидорович');
 Course.Add('4','Иванов','Роман','Романович');
 Course.Print('Вывод списка студентов и сохранение в файл');
 Course.Save;
 
 Course.Sort(sfMiddleName);
 Course.Print('Сортировка по имени');
 Course.Sort(sfNumber);
 Course.Print('Сортировка по номеру');
 Course.Sort(sfFirstName);
 Course.Print('Сортировка по фамилии');
 
 Course.Init;
 Course.Print('Очистка списка');
 Course.Load;
 Course.Print('Восстановление из файла и отображение списка');
end;
 
end.
Что не так?
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
10.12.2017, 15:45
Ответы с готовыми решениями:

Встречено 'End', а ожидалось begin
Что-то не так с циклами видимо, может свежий взгляд обнаружит ошибку? В строку 48 ругается. ...

Встречено 'end', а ожидалось begin
Не могу найти ошибку. uses GraphABC, ABCObjects; var a: ABCObjects.PictureABC; b:...

Встречено 'end', а ожидалось begin
Друзья спасайте В конце на последней строчке пишет Встречено 'end', а ожидалось begin не пойму в...

Встречено 'Begin', а ожидалось выражение
Нужна помощь! При программирование у меня возникла проблема. Встречено 'Begin', а ожидалось...

1
Супер-модератор
Эксперт Pascal/DelphiАвтор FAQ
32627 / 21094 / 8139
Регистрация: 22.10.2011
Сообщений: 36,357
Записей в блоге: 8
10.12.2017, 15:51 2
Лишние точки с запятой, недостаток end-ов. Вот так код будет компилироваться:

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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
uses Crt;
 
Const
    MaxRec = 4;
Type
    String11 = String[11];
    String25 = String[25];
    TStudent = record
     Number : ShortString;
     FirstName,
     MiddleName,
     LastName: String25;
    end;
    TSortField = (sfNumber, sfFirstName, sfMiddleName);
    TCourse = object
     Count : Integer;
     Students : Array[1..MaxRec] of TStudent;
     constructor Init;
     procedure Add(Number: String11; FirstName, MiddleName, LastName: String25);
     procedure Del(Number: String11);
     procedure Sort(SortField: TSortField);
     procedure Print(Title: String);
     procedure Save;
     procedure Load;
    end;
 
    constructor TCourse.Init;
    begin
     Self.Count := 0;
    end;
 
    procedure TCourse.Add(Number: String11; FirstName, MiddleName, LastName: String25);
    begin
     if Count + 1 > MaxRec then Exit;
     Inc(Count);
     Students[Count].Number := Number;
     Students[Count].FirstName := FirstName;
     Students[Count].MiddleName := MiddleName;
     Students[Count].LastName := LastName;
    end;
 
    procedure TCourse.Del(Number: String11);
    var i,j: Integer;
    begin
     for i := 1 to Count
     do if Students[i].Number = Number
        then begin
             for j := i to Count - 1
             do Students[j] := Students[j+1];
             Dec(Count);
             end;
    end;
 
    procedure TCourse.Sort(SortField: TSortField);
     procedure Exchange(var Rec1, Rec2: TStudent);
     var Tmp: TStudent;
     begin
      Tmp := Rec1;
      Rec1 := Rec2;
      Rec2 := Tmp;
     end;
    var i,j: Integer;
    begin
     for i := 1 to Count
     do for j := i+1 to Count
        do case SortField
           of sfNumber:
              if Students[j].Number < Students[i].Number
              then Exchange(Students[j], Students[i]);
              sfFirstName:
              if Students[j].FirstName < Students[i].FirstName
              then Exchange(Students[j], Students[i]);
              sfMiddleName:
              if Students[j].MiddleName < Students[i].MiddleName
              then Exchange(Students[j], Students[i]);
           end;
    end;
 
    procedure TCourse.Print(Title: String);
    var i: Integer;
    begin
     WriteLn(Title);
     for i := 1 to Count
     do with Students[i]
        do WriteLn(Number,' ',FirstName,' ',MiddleName,' ',LastName);
    end;
 
    procedure TCourse.Save;
    var
       F: File of TStudent;
       i: Integer;
    begin
     Assign(F, 'Student.dat');
     Rewrite(F);
     for i := 1 to Count
     do Write(F, Students[i]);
     Close(F);
    end;
 
    procedure TCourse.Load;
    var
       F: File of TStudent;
       i: Integer;
       Rec: TStudent;
    begin
     Init;
     Assign(F, 'Student.dat');
     Reset(F);
     while not Eof(F)
     do begin
        Read(F, Rec);
        Add(Rec.Number,Rec.FirstName,Rec.MiddleName,Rec.LastName);
        end;
     Close(F);
    end;
 
var
   Course: TCourse;
begin
 ClrScr;
 Course.Init;
 Course.Add('1','Иванов','Степан','Сергеевич');
 Course.Add('2','Петров','Никита','Александрович');
 Course.Add('3','Сидоров','Алексей','Сидорович');
 Course.Add('4','Иванов','Роман','Романович');
 Course.Print('Вывод списка студентов и сохранение в файл');
 Course.Save;
 
 Course.Sort(sfMiddleName);
 Course.Print('Сортировка по имени');
 Course.Sort(sfNumber);
 Course.Print('Сортировка по номеру');
 Course.Sort(sfFirstName);
 Course.Print('Сортировка по фамилии');
 
 Course.Init;
 Course.Print('Очистка списка');
 Course.Load;
 Course.Print('Восстановление из файла и отображение списка');
end.
(проверил в FPC, так что особо камни не кидать...)
1
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
10.12.2017, 15:51
Помогаю со студенческими работами здесь

Встречено 'end', а ожидалось ';'
program qq; var x, y, k, i: integer; begin repeat X:= random(10)+1; y:= random(10)+1; i:=0;...

Встречено end, а ожидалось ';'
в 52 строке выдаёт ошибку &quot;встречено end, а ожидалось &quot;;&quot; помогите пожалуйста :wall: var...

Встречено 'end', а ожидалось ';'
Помогите! В 31 строке ошибка Встречено 'end', а ожидалось ';' :wall: const n=6;m=4; var a:array...

Ошибка: Встречено 'end', а ожидалось ';'
Ребята, помогите пожалуйста. Только начал програмировать на паскале может чего то не понимаю но...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
2
Ответ Создать тему
Опции темы

КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2023, CyberForum.ru