I got Compilation Error!!! What is wrong??? ----------------PROGRAM--------------- const col:array[1..10]of char = ('A','B','C','G','O','R','S','V','W','Y'); var a:array[1..10,1..10,1..10,1..10]of integer; hash1:array[0..255]of integer; N,k,max,i,k1,k2,k3,k4:integer; f,r,l,re,t,b:char; s,rrr:string; procedure addnew; var min:char; i,l:integer; begin rrr[0]:=#4; min:=#255; for i:=1 to 4 do if s[i]<min then begin min:=s[i]; l:=i; end; for i:=l to 4 do rrr[i-l+1]:=s[i]; for i:=1 to l-1 do rrr[i+4-l+1]:=s[i]; inc(a[ord(rrr[1]),ord(rrr[2]),ord(rrr[3]),ord(rrr[4])]); end; begin for i:=1 to 10 do hash1[ord(col[i])]:=i; { assign(input,'1127.dat');reset(input);} readln(N); for k:=1 to N do begin readln(s); for i:=1 to 6 do s[i]:=chr(hash1[ord(s[i])]); f:=s[1];r:=s[2];l:=s[3];re:=s[4];t:=s[5];b:=s[6]; s[0]:=#4; s[1]:=f;s[2]:=l;s[3]:=re;s[4]:=r; addnew; s[1]:=t;s[2]:=re;s[3]:=b;s[4]:=f; addnew; s[1]:=t;s[2]:=r;s[3]:=b;s[4]:=l; addnew; end; max:=0; for k1:=1 to 10 do for k2:=1 to 10 do for k3:=1 to 10 do for k4:=1 to 10 do if a[k1,k2,k3,k4]>max then max:=a[k1,k2,k3,k4]; writeln(max); end. You cannot access 0-the element of string. (+) If they use delphi compiler, then the error can be next---Just follow the line :) | > const col:array[1..10]of char = | > ('A','B','C','G','O','R','S','V','W','Y'); | > var | > a:array[1..10,1..10,1..10,1..10]of integer; | > hash1:array[0..255]of integer; | > N,k,max,i,k1,k2,k3,k4:integer; | > f,r,l,re,t,b:char; | > s,rrr:string; | > | > procedure addnew; | > var min:char; | > i,l:integer; | > begin | > rrr[0]:=#4; <<<- I think this can be an error.<<<-----/ > min:=#255; | > for i:=1 to 4 do if s[i]<min then | > begin | > min:=s[i]; | > l:=i; | > end; | > for i:=l to 4 do rrr[i-l+1]:=s[i]; | > for i:=1 to l-1 do rrr[i+4-l+1]:=s[i]; \--> inc(a[ord(rrr[1]),ord(rrr[2]),ord(rrr[3]),ord(rrr[4])]); | > end; /--/ > | > begin | > for i:=1 to 10 do hash1[ord(col[i])]:=i; | > { assign(input,'1127.dat');reset(input);} | > readln(N); | > for k:=1 to N do | > begin | > readln(s); | > for i:=1 to 6 do | > s[i]:=chr(hash1[ord(s[i])]); | > f:=s[1];r:=s[2];l:=s[3];re:=s[4];t:=s[5];b:=s[6]; | > s[0]:=#4; <<< And probably this too <<<-------------/ > s[1]:=f;s[2]:=l;s[3]:=re;s[4]:=r; > addnew; > s[1]:=t;s[2]:=re;s[3]:=b;s[4]:=f; > addnew; > s[1]:=t;s[2]:=r;s[3]:=b;s[4]:=l; > addnew; > end; > max:=0; > for k1:=1 to 10 do for k2:=1 to 10 do for k3:=1 to 10 do for k4:=1 > to 10 do > if a[k1,k2,k3,k4]>max then max:=a[k1,k2,k3,k4]; > writeln(max); > end. Re: Thank's! > Thank's!hahaha |