我无法理解这里发生了什么.你能帮我个忙吗?这是有问题的代码:
While not EOF(Archi) do begin
index:= index + 1;
Read(Archi, Alumno[index]);
Promes[index] := (Alumno[index].nota1 + Alumno[index].nota2) / 2;
if Promes[index] >= 6 then begin
alguPromo := true;
PromosIndex := PromosIndex + 1;
Promos[PromosIndex]:= Alumno[index];
end;
else begin
if Promes[index] > 4 then cantiRecu:= cantiRecu + 1;
else begin
LibresIndex += 1;
Libres[LibresIndex] := Alumno[index];
end;
end;
end;
Run Code Online (Sandbox Code Playgroud)
编译器在此代码的第10行标记错误(否则开始).错误是:致命:语法错误,; 预期,但ELSE发现.
如果有人想要托盘编译这里是整个代码:http://pastebin.com/dRg1Lguu
请注意,在Pascal中,分号是分隔符,而不是终结符.有时候这并不重要,但在某些情况下确实如此,尤其是在此之前else.你的代码应该是:
while not EOF(Archi) do
begin
index:= index + 1;
Read(Archi, Alumno[index]);
Promes[index] := (Alumno[index].nota1 + Alumno[index].nota2) / 2;
if Promes[index] >= 6 then
begin
alguPromo := true;
PromosIndex := PromosIndex + 1;
Promos[PromosIndex] := Alumno[index]
end
else
begin
if Promes[index] > 4 then
cantiRecu:= cantiRecu + 1
else
begin
LibresIndex := LibresIndex + 1;
Libres[LibresIndex] := Alumno[index]
end
end
end
Run Code Online (Sandbox Code Playgroud)
请注意,我已经将代码重新格式化为更传统的样式,这有助于使程序逻辑更容易理解,这也使得分号需要的地方和不需要分号的地方更加明显.
| 归档时间: |
|
| 查看次数: |
4108 次 |
| 最近记录: |