It is necessary from file 1 to file 2 to transfer the city to which it takes less than 4 hours. I have an error somewhere with types ... i.e. he reads time in TXT and cannot compare it with the usual number or does not read time. How to fix it? Here is the text of the program

program lab3; uses crt; var time:0..5; gorod:real; fin, fout:text; begin clrscr; assign(fin,'1.txt'); assign(fout,'2.txt'); reset(fin); rewrite(fout); writeln(fout, 'gorod do kotorogo letet menee 4 chasov'); repeat readln(fin,gorod,time); until eof(fin) or (time<=4); if eof(fin) then writeln('takogo net') else writeln(fout, gorod, time); close(fin); close(fout); end. 

    1 answer 1

    Unfortunately, the compiler is not at hand, but try rewriting the main logical part of your program to make it clearer what is going on. And if there are still errors, then it is worthwhile to try and understand what is the matter.

     var time:Integer; gorod:Real; { Непонятно, почему Real, а не String, например, но почему бы и нет } { ... } repeat readln(fin, gorod, time); if time in [1..4] then begin writeln(fout, gorod, time); break; end until eof(fin) { Если у нас все-таки случился конец файла, то значит ничего не нашли } writeln(fout, 'Takogo net.'); { ... }