ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1044. Lucky Tickets. Easy!

Why do I get Compilation Error ???
Posted by ValBG 28 Mar 2002 10:10
 This is my program and it works PERFECTLY well on Pascal. Why does
it get this ERROR on the online compilator???

 Program valeria(input,output);
 Var N,M:0..9;
     A:array[1..9]of 0..9;
     D:array[0..36]of word;
     k,s,i:longint;
     ch:char;

 Procedure Count;
   begin
     s:=0;
     for i:=1 to M do S:=S+A[i];
     Inc(D[s])
   end;

 Begin
   K:=0;
   for i:=1 to 36 do D[i]:=0;
   readln(N);
   M:=N div 2;
   if N=0 then K:=0 else
     if (N=1)or(N=2) then K:=10 else
        if N=3 then K:=100 else
      begin
        for A[1]:=0 to 9 do
          for A[2]:=0 to 9 do if M=2 then Count else
            for A[3]:=0 to 9 do if M=3 then Count else
              for A[4]:=0 to 9 do Count;
        K:=0;
        for i:=0 to M*9 do K:=K+sqr(D[i]);
        if N mod 2<>0 then K:=K*10;
      end;
   writeln(K);
 End.
Re: Why do I get Compilation Error ???
Posted by MadPsyentist/Sam 28 Mar 2002 13:14
>  This is my program and it works PERFECTLY well on Pascal. Why
does
> it get this ERROR on the online compilator???
>
>  Program valeria(input,output);
>  Var N,M:0..9;
>      A:array[1..9]of 0..9;
>      D:array[0..36]of word;
>      k,s,i:longint;
>      ch:char;
>
>  Procedure Count;
>    begin
>      s:=0;
>      for i:=1 to M do S:=S+A[i];
>      Inc(D[s])
>    end;
>
>  Begin
>    K:=0;
>    for i:=1 to 36 do D[i]:=0;
>    readln(N);
>    M:=N div 2;
>    if N=0 then K:=0 else
>      if (N=1)or(N=2) then K:=10 else
>         if N=3 then K:=100 else
>       begin
>         for A[1]:=0 to 9 do
>           for A[2]:=0 to 9 do if M=2 then Count else
>             for A[3]:=0 to 9 do if M=3 then Count else


I compiled your program on DevPascal and found error in this line
Error: Illegal counter variable
>               for A[4]:=0 to 9 do Count;



>         K:=0;
>         for i:=0 to M*9 do K:=K+sqr(D[i]);
>         if N mod 2<>0 then K:=K*10;
>       end;
>    writeln(K);
>  End.