Uses Crt to use Readkey function ----> compiler error

Write here if you have problems with your Pascal source code

Moderator: Board moderators

Post Reply
leeyeanhoo
New poster
Posts: 4
Joined: Sat Nov 04, 2006 5:40 am

Uses Crt to use Readkey function ----> compiler error

Post by leeyeanhoo » Sat Nov 04, 2006 6:26 am

Hello

I trying to use readkey but it always get compiler error on online-judge


Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.

C:\PASCAL>fpc -dONLINE_JUDGE -Sd testasso.pas
Free Pascal Compiler version 2.0.4 [2006/08/21] for i386
Copyright (c) 1993-2006 by Florian Klaempfl
Target OS: Win32 for i386
Compiling testasso.pas
Linking testasso.exe
49 Lines compiled, 1.2 sec

C:\PASCAL>



But as you can see there is no problem with compiling

Coundt I use readkey function using 'uses CRT' ??

How could I substitute readkey function for another?

please helpme

leeyeanhoo
New poster
Posts: 4
Joined: Sat Nov 04, 2006 5:40 am

Problem is about input!

Post by leeyeanhoo » Sat Nov 04, 2006 6:12 pm

Var
Num,I,J : Real;
Length,Maior,contador : Word;
Begin


While Not Eof(Input) Do
Begin

Readln(I,J);
Write(I:1:0,' ',J:1:0,' ');
Maior := 0;

For Contador := Trunc(J) Downto Trunc(I) Do
Begin
Length :=1;
Num := Contador;
While Num <> 1 Do
If (trunc(Num) mod 2) = 0 Then
Begin
Num := Num / 2;
Length := Length + 1;
End
Else
Begin
Num := (Num * 3) + 1;
Length := Length+1;
End;

If Maior < Length Then
Maior := Length;
End;

Writeln(Maior);

End;
End.



This is my code to problem 100
but always i got TIME limit EXCEDEED!!
What is problem with my code?

henry1007
New poster
Posts: 4
Joined: Thu Apr 19, 2007 7:28 pm

Re: Problem is about input!

Post by henry1007 » Sat Apr 21, 2007 9:28 pm

leeyeanhoo wrote: This is my code to problem 100
but always i got TIME limit EXCEDEED!!
What is problem with my code?
I wonder y u got a TLE rather than RE - the maximum allowed integer is 999999, yet the range of Word is 0-65536.
Also, y bother reading numbers in Real and trunc them in calculations?
Use LongInt directly should help.

Post Reply

Return to “Pascal”