最近在学深搜和广搜
http://acm.fzu.这道题用深搜要怎么写,哪位前辈能把核心的那部分写给偶瞧下吗
program fz1301; var n:integer; a:array[1..7,0..7] of integer; min:longint; procedure init; var i,j:integer; begin fillchar(a,sizeof(a),0); for i:=1 to n do for j:=1 to n do read(a[i,j]); min:=10000000; end; function myadd(a,b:integer):integer; begin exit((a+b-1) mod n+1); end; procedure update; var mymax:integer; sum:array[1..7] of integer; i,j:integer; begin fillchar(sum,sizeof(sum),0); for i:=1 to n do {columns} for j:=1 to n do {rows} inc(sum[i],a[j,myadd(a[j,0],i)]); mymax:=-1; for i:=1 to n do if sum[i]>mymax then mymax:=sum[i]; if mymax<min then min:=mymax; end; procedure search(row:integer); var i,j,k:integer; sum:array[1..7] of integer; {integer = longint} begin if row=n+1 then update else begin for j:=0 to n-1 do begin a[row,0]:=j; search(row+1); end; end; end; begin read(n); while n<>-1 do begin init; search(1); writeln(min); readln(n); end; end.