Page 1 of 1

Compile Time Error?

Posted: Wed May 28, 2003 10:13 pm
by playerX
I personnaly don't like to post or read code from forums but this is getting really annoying, I do not receive any compile error message from the server but I still get CE.... Is my code taking too long to compile???

[pascal]Program ReverseAndAdd;
Var N,I,Num:integer;

Function Reverse(N:Integer):Integer;
Var TempMatch,ResultadoD:String;
I:Integer;
Begin
TempMatch:=''; ResultadoD:='';
Str(N,TempMatch);
For I:=Length(TempMatch) DownTo 1 Do
Begin
ResultadoD:=Concat(ResultadoD,TempMatch);
End;
Val(ResultadoD,Reverse,Reverse);
End;

Procedure Solve(Num:Integer);
Var Sum1,Sum2:Integer;
Resultado:Integer;
I:Integer;
Begin
I:=1;
Resultado:=0;
Sum1:=Num;
Sum2:=Reverse(Num);
Resultado:=Sum1+Sum2;
Repeat
Inc(I);
Sum1:=Resultado; Sum2:=Reverse(Resultado);
Resultado:=Sum1+Sum2;
Until Resultado=Reverse(Resultado);
WriteLn(I,' ',Resultado);
End;

Begin
ReadLn(Input,N);
For I:=1 To N Do
Begin
ReadLn(Input,Num);
Solve(Num);
End;
End.[/pascal]

eheh

Posted: Wed May 28, 2003 10:35 pm
by ACoimbra
well, I can't find a mistake, although I would like to sugest that you try to avoid complicated stuff, try to make your code as simple as possible, it will be easier to debug and also you won't get so many problems.