永发信息网

pascal问题转换图形

答案:2  悬赏:30  手机版
解决时间 2021-05-03 01:15

一块N x N(1<=N<=10)正方形的黑白瓦片的图案要被转换成新的正方形图案。写一个程序来找出将原始图案按照以下列转换方法转换成新图案的最小方式:

1:转90度:图案按顺时针转90度。

2:转180度:图案按顺时针转180度。

3:转270度:图案按顺时针转270度。

4:反射:图案在水平方向翻转(以中央铅垂线为中心形成原图案的镜像)。

5:组合:图案在水平方向翻转,然后再按照1到3之间的一种再次转换。

6:不改变:原图案不改变。

7:无效转换:无法用以上方法得到新图案。

如果有多种可用的转换方法,请选择序号最小的那个。


[编辑] 格式

PROGRAM NAME: transform

INPUT FORMAT:

(file transform.in)

第一行: 单独的一个整数N。

第二行到第N+1行: N行每行N个字符(不是“@”就是“-”);这是转换前的正方形。

第N+2行到第2*N+1行: N行每行N个字符(不是“@”就是“-”);这是转换后的正方形。

OUTPUT FORMAT:

(file transform.out)

单独的一行包括1到7之间的一个数字(在上文已描述)表明需要将转换前的正方形变为转换后的正方形的转换方法。

[编辑] SAMPLE INPUT

3

@—@

———

@@—

@—@

@——

——@

[编辑] SAMPLE OUTPUT

1

来自" http://www.nocow.cn/index.php/Translate:USACO/transform"
最佳答案
可以考虑模拟每一个情况的结果与需要的结果进行对比(从1开始到最后),只要有一种可能了就可以输出该序号了。
全部回答
var  c1,c2,c3,c4,c5:array[1..11] of string;  n,ii:longint;  x1:boolean; procedure rr;  var   i:longint;  begin   readln(n);   for i:=1 to n do readln(c1[i]);   for i:=1 to n do readln(c2[i]);  end; procedure one;  var i,j:longint; x:boolean;  begin   x:=true;   for i:=1 to n do c4[i]:='';   for i:=1 to n do for j:=1 to n do c4[j]:=c4[j]+c3[n-i+1][j];   for i:=1 to n do if c2[i]<>c4[i] then x:=false;   if x1 then if x then begin writeln('1'); halt; end;  end; procedure two;  var i,j:longint; x:boolean;  begin   x:=true;   for i:=1 to n do c4[i]:='';   for i:=1 to n do for j:=1 to n do c4[j]:=c4[j]+c3[n-i+1][j];   for i:=1 to n do if c2[i]<>c4[i] then x:=false;   if x1 then if x then begin writeln('2'); halt; end;  end; procedure three;  var i,j:longint; x:boolean;  begin   x:=true;   for i:=1 to n do c4[i]:='';   for i:=1 to n do for j:=1 to n do c4[j]:=c4[j]+c3[n-i+1][j];   for i:=1 to n do if c2[i]<>c4[i] then x:=false;   if x1 then if x then begin writeln('3'); halt; end;  end; procedure four;  var i,j:longint; x:boolean;  begin   x:=true;   for i:=1 to n do c4[i]:='';   for i:=1 to n do for j:=n downto 1 do c4[i]:=c4[i]+c1[i][j];   for i:=1 to n do if c2[i]<>c4[i] then x:=false;   for i:=1 to n do c5[i]:=c4[i];   if x1 then if x then begin writeln('4'); halt; end;  end; procedure five;  var   i:longint; x:boolean;  begin   x1:=false;   x:=true;   four;   for i:=1 to n do c3[i]:=c5[i];   one;   for i:=1 to n do if c2[i]<>c4[i] then x:=false;   if x then begin writeln('5'); halt; end;   for i:=1 to n do c3[i]:=c4[i];   two;   x:=true;   for i:=1 to n do if c2[i]<>c4[i] then x:=false;   if x then begin writeln('5'); halt; end;   for i:=1 to n do c3[i]:=c4[i];   three;   for i:=1 to n do if c2[i]<>c4[i] then x:=false;   if x then begin writeln('5'); halt; end;  end; procedure six;  var i:longint; x:boolean;  begin   x:=true;   for i:=1 to n do if c1[i]<>c2[i] then x:=false;   if x then begin writeln('6'); halt; end;  end; begin  assign(input,'transform.in');  reset(input);  assign(output,'transform.out');  rewrite(output);  x1:=true;  rr;  for ii:=1 to n do c3[ii]:=c1[ii];  one;  x1:=true;  for ii:=1 to n do c3[ii]:=c4[ii];  two;  x1:=true;  three;  x1:=true;  four;  x1:=true;  five;  x1:=true;  six;  writeln('7');  close(input);  close(output); end.
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
有经验的帮我参考下我们区70简易腰带多少钱(
做俯卧撑或者飞鸟会拉宽肩膀吗?
大学的学习方法?是不是和高中的学习不一样呀!
我是河北人,在河南上的大学,现在马上就毕业
说说而已本意是什么。
手机呼叫限制密码锁了
宝乐有佳宠物诊所怎么去啊,有知道地址的么
电影神话玉漱经典台词,《神话》里玉漱的独白
希澈单独唱的再没有我这样的人了的下载地址
我冲不到钱.怎么办?
手机上网GPRS1兆等于多少KB
怎么恢复在任务栏通知区域显示QQ图标
友友们现在海信TLM26E29型电视市场价要多少?
电脑卡 反应慢 卡屏 是什么原因?
三本能上哪些沙坪坝的大学
推荐资讯
中国农业银行瑞昌赛湖分理处地址在哪,我要去
有好多人在耍魔域?
爱流清鼻涕是鼻炎吗
怎么才能多吃还能减肥?
不为别人着想的句子,为别人着想的话有哪些?
跑堂~是什么噢?
永恒之塔48级杀星 挂什么掉神石头掉的高
为什么近期使用四海加速器总是掉线?
一粒红尘的唯美句子,谁能提供些关于有"红尘"
手机登录收费吗?收多少?
巴黎龙虾怎么去啊,有知道地址的么
他是个又懒又不负责任的人这日子怎么过嘛
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?