看题目请猛击这里 重要的公式: 顺时针旋转90度:c[j,n-i+1]:=a[i,j]; 水平方向的翻转:c[i,n-j+1]:=a[i,j]; 然后知道了这些就能把代码写出来了。 七种情况依次模拟转换过程。: { ID:asdcyt01 PROB:transform LANG:PASCAL } program transform(input,output); type formtype=array[1..10,1..10]of char; var n,i,j:longint; a,b:formtype; success:boolean; function compare(x,y:formtype):boolean; var i,j:longint; begin for i:=1 to n do for j:=1 to n do if x[i,j]<>y[i,j] then exit(false); exit(true); end; function convert(x:longint):boolean; var c:formtype; i,j,k:longint; begin case x of 1: begin for i:=1 to n do for j:=1 to n do c[j,n-i+1]:=a[i,j]; if compare(b,c) then exit(true) else exit(false); end; 2: begin c:=a; for k:=1 to 2 do for i:=1 to n do for j:=1 to n do c[j,n-i+1]:=c[i,j]; if compare(b,c) then exit(true) else exit(false); end; 3: begin c:=a; for k:=1 to 3 do for i:=1 to n do for j:=1 to n do c[j,n-i+1]:=c[i,j]; if compare(b,c) then exit(true) else exit(false); end; 4: begin for i:=1 to n do for j:=1 to n do c[i,n-j+1]:=a[i,j]; if compare(b,c) then exit(true) else exit(false); end; 5: begin for i:=1 to n do for j:=1 to n do c[i,n-j+1]:=a[i,j]; for i:=1 to 3 do if convert(i)then exit(true); exit(false); end; 6: if compare(a,b) then exit(true) else exit(false); end; end; begin assign(input,'transform.in');reset(input); assign(output,'transform.out');rewrite(output); readln(n); for i:=1 to n do begin for j:=1 to n do read(a[i,j]); readln; end; for i:=1 to n do begin for j:=1 to n do read(b[i,j]); readln; end; for i:=1 to 7 do if convert(i) then begin success:=true; writeln(i); break; end; if not success then writeln('7'); close(input);close(output); end .