program Noname4;
function minutes (Amin, Bmin :integer) : integer;
function time (Aval, Bval :integer) : integer;
begin
if (0 <= Aval) and (Bval < 24) then
time :=Bval - Aval;
if (0 <= Amin) and (Bmin < 60) then
minutes :=Bmin - Amin;
end;
var Aval, Amin, Bval, Bmin, n , x , i , y :integer;
duom, rez : text;
begin
readln(Aval, Amin, Bval, Bmin );
writeln(time(Aval, Bval));
writeln(minutes(Amin, Bmin));
readln;
assign(duom, 'Duomenys2.txt');
Reset(duom);
Readln(duom, n );
assign(rez, 'rezultatai2.txt');
rewrite(rez);
for i := 1 to n do
begin
Readln(duom, Aval, Amin, Bval, Bmin);
x := time(Aval, Bval);
y := minutes (Amin, Bmin);
writeln(rez, x);
writeln(rez, y);
end;
close(duom);
close(rez);
end.你好,我收到了一个错误(重复标识符,已经在第2行中定义的标识符)。它在( duom,rez : text;)行中显示红色。找不出原因
program Noname4;
function minutes (Amin, Bmin :integer) : integer;
function time (Aval, Bval :integer) : integer;
begin
if (0 <= Aval) and (Bval < 24) then
time :=Bval - Aval;
if (0 <= Amin) and (Bmin < 60) then
minutes :=Bmin - Amin;
end;
var Aval, Bval, n , x , i , y :integer;
duom, rez : text;
begin
assign(duom, 'Duomenys2.txt');
Reset(duom);
Readln(duom, n );
assign(rez, 'Rezultatai2.txt');
rewrite(rez);
for i := 1 to n do
begin
Readln(duom, Aval, Bval, Amin, Bmin);
x := time(Aval, Bval);
y := minutes(Amin, Bmin);
writeln(rez, x);
writeln(rez, y);
end;
close(duom);
close(rez);
end;
begin
end.我按照你说的做了,这个程序现在运行得很好,只是它没有把答案写在‘Rezultalai2.txt’文件中。
发布于 2015-01-02 15:18:44
改变:
var Aval, Amin, Bval, Bmin, n , x , i , y :integer;
duom, rez : text;至:
var Aval, Bval, n , x , i , y :integer;
duom, rez : text;它们已经被定义为传递到分钟函数中的变量。
https://stackoverflow.com/questions/27744246
复制相似问题