Pascal没有在文本文件中写入结果

时间:2015-01-02 17:10:27

标签: freepascal

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.

该程序运行正常,没有错误,但没有在(Rezultatai2.txt)文件中写入结果。我认为它没有读取指定的文件(Duomenys2.txt),因为我在那里写任何我想要的东西,它仍然有效。

1 个答案:

答案 0 :(得分:2)

您的计划实际上是空的。程序的开始/结束之间没有代码。因此,您的程序在执行时,即使它编译得很好并且不会导致运行时错误,也不会做任何有用的事情。