| 
 | 
вернуться в форумWhy did my program compile error? In this program n is k , k is n var   l : array [1..1000] of byte;   n , k , ss : integer;   tot : longint; function cf(aa,bb:integer) : longint; var   temp , ii : longint; begin   temp := 1;   for ii := 1 to bb do     temp := temp * aa;   cf := temp; end; procedure try(now,left,source : integer); var   jj : byte; begin   if left = 0 then begin     tot := tot + cf(n-1,k-source);     exit;   end;   if now > k then exit;   if left > k - now+1 then exit;   for jj := 0 to 1 do     if (jj = 0) or ((jj=1) and (l[now-1]<>1)) then begin       l[now] := jj;       try(now+1 , left-jj , source);     end; end;   begin   readln(k);   readln(n);   tot := cf(n-1,k);   for ss := 1 to k-1 do    try(2,ss,ss);   writeln(tot); end. Re: Why did my program compile error? > In this program n is k , k is n > var >   l : array [1..1000] of byte; >   n , k , ss : integer; >   tot : longint; > function cf(aa,bb:integer) : longint; > var >   temp , ii : longint; > begin >   temp := 1; >   for ii := 1 to bb do >     temp := temp * aa; >   cf := temp; > end; > procedure try(now,left,source : integer); > var >   jj : byte; > begin >   if left = 0 then begin >     tot := tot + cf(n-1,k-source); >     exit; >   end; >   if now > k then exit; >   if left > k - now+1 then exit; >   for jj := 0 to 1 do >     if (jj = 0) or ((jj=1) and (l[now-1]<>1)) then begin >       l[now] := jj; >       try(now+1 , left-jj , source); >     end; > end; > > begin >   readln(k); >   readln(n); >   tot := cf(n-1,k); >   for ss := 1 to k-1 do >    try(2,ss,ss); >   writeln(tot); > end. > 1. warning: missing program header; With header my GPC compiled your program? but ... 2. While trying to solve this problem and checking my e-mail i find one error: function or procedure can't use name 'try'. When i change 'try' in your program to 'trye', your program solve the problem. Thank you for your code :-) Header?What is it?Turbo Pascal doesn't need header? I've known that procedure or function name can't use "try".Thank you for your help.  |  
  | 
|