|  | 
|  | 
| back to board | Why didi I get 'Compilation error'? Posted by 123789  23 Nov 2007 10:00I can run it in FP,but if I put it on,it will showed'Compilation error'.Who can tell me why?
 
 var
 n,i,j,t,l:longint;
 a:array[0..1000] of longint;
 c:array[0..1000] of boolean;
 f:array[0..50000,0..1000] of boolean;
 begin
 readln(n);
 for i:=1 to n do readln(a[i]);
 c[0]:=true;f[0,0]:=true;
 for i:=1 to n do
 for j:=n downto a[i] do
 if c[j-a[i]] then begin
 c[j]:=true;
 
 for l:=0 to i-1 do
 
 if f[j-a[i],l] then
 f[j,l]:=true;
 f[j,i]:=true;
 if j=n then begin
 for i:=1 to i do
 if f[n,i] then inc(t);
 writeln(t);
 for i:=1 to i do
 if f[n,i] then writeln(a[i]);halt;
 end;
 end;
 writeln(0);
 end.
 
Re: Why didi I get 'Compilation error'? varn,i,j,t,l:longint;
 a:array[0..1000] of longint;
 c:array[0..1000] of boolean;
 f:array[0..50000,0..1000] of boolean;
 begin
 readln(n);
 for i:=1 to n do readln(a[i]);
 c[0]:=true;f[0,0]:=true;
 for i:=1 to n do           //If you use var i here
 for j:=n downto a[i] do
 if c[j-a[i]] then begin
 c[j]:=true;
 
 for l:=0 to i-1 do
 
 if f[j-a[i],l] then
 f[j,l]:=true;
 f[j,i]:=true;
 if j=n then begin
 for i:=1 to i do            // then you can not use it inside cycle
 if f[n,i] then inc(t);
 writeln(t);
 for i:=1 to i do
 if f[n,i] then writeln(a[i]);halt;
 end;
 end;
 writeln(0);
 end.
 
 You can choose "send reply on my email" for explanations
 
 Edited by author 23.11.2007 15:59
Re: Why didi I get 'Compilation error'? Thanks a lot | 
 | 
|