题目描述                     Description

一块N x N(1<=N<=10)正方形的黑白瓦片的图案要被转换成新的正方形图案。写一个程序来找出将原始 图案按照以下列转换方法转换成新图案的最小方式: #1:转90度:图案按顺时针转90度。 #2:转180度:图案按顺时针转180度。 #3:转270度:图案按顺时针转270度。 #4:反射:图案在水平方向翻转(形成原图案的镜像)。 #5:组合:图案在水平方向翻转,然后按照#1-#3之一转换。 #6:不改变:原图案不改变。 #7:无效转换:无法用以上方法得到新图案。 如果有多种可用的转换方法,请选择序号最小的那个。

输入描述 Input Description              
第一行: 单独的一个整数N。
第二行到第N+1行: N行每行N个字符(不是“@”就是“-”);这是转换前的正方形。
第N+2行到第2*N+1行: N行每行N个字符(不是“@”就是“-”);这是转换后的正方形。
输出描述                 Output Description              

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

                样例输入                 Sample Input              

3 @-@ --- @@- @-@ @-- --@

样例输出                 Sample Output              

1

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath> using namespace std; char s1[][];
char s2[][];
char s3[][];
char s4[][]; int main()
{
int n,i,j;
cin>>n;
for(i = ;i<=n;i++)
scanf("%s",s1[i]+);
for(i = ;i<=n;i++)
scanf("%s",s2[i]+);
for(i = ;i<=n;i++)
for(j = ;j<=n;j++)
{
s3[j][n-i+] = s1[i][j];
}
bool b = ;
for(i = ;i<=n;i++)
for(j = ;j<=n;j++)
if(s3[i][j]!=s2[i][j]) b = ;
if(b)
{
cout<<<<endl;
return ;
}
for(i = ;i<=n;i++)
for(j = ;j<=n;j++)
{
s4[j][n-i+] = s3[i][j];
}
b = ;
for(i = ;i<=n;i++)
for(j = ;j<=n;j++)
if(s4[i][j]!=s2[i][j]) b = ;
if(b)
{
cout<<<<endl;
return ;
}
for(i = ;i<=n;i++)
for(j = ;j<=n;j++)
{
s3[j][n-i+] = s4[i][j];
}
b = ;
for(i = ;i<=n;i++)
for(j = ;j<=n;j++)
if(s3[i][j]!=s2[i][j]) b = ;
if(b)
{
cout<<<<endl;
return ;
}
for(i = ;i<=n;i++)
{
for(j = ;j<=n;j++)
{
s3[i][n-j+] = s1[i][j];
}
}
b = ;
for(i = ;i<=n;i++)
for(j = ;j<=n;j++)
if(s3[i][j]!=s2[i][j]) b = ;
if(b)
{
cout<<<<endl;
return ;
}
for(i = ;i<=n;i++)
for(j = ;j<=n;j++)
{
s4[j][n-i+] = s3[i][j];
}
b = ;
for(i = ;i<=n;i++)
for(j = ;j<=n;j++)
if(s4[i][j]!=s2[i][j]) b = ;
if(b)
{
cout<<<<endl;
return ;
}
for(i = ;i<=n;i++)
for(j = ;j<=n;j++)
{
s3[j][n-i+] = s4[i][j];
}
b = ;
for(i = ;i<=n;i++)
for(j = ;j<=n;j++)
if(s3[i][j]!=s2[i][j]) b = ;
if(b)
{
cout<<<<endl;
return ;
}
for(i = ;i<=n;i++)
for(j = ;j<=n;j++)
{
s4[j][n-i+] = s3[i][j];
}
b = ;
for(i = ;i<=n;i++)
for(j = ;j<=n;j++)
if(s4[i][j]!=s2[i][j]) b = ;
if(b)
{
cout<<<<endl;
return ;
}
b = ;
for(i = ;i<=n;i++)
for(j = ;j<=n;j++)
if(s1[i][j]!=s2[i][j]) b = ;
if(b)
{
cout<<<<endl;
return ;
}
cout<<<<endl;
return ;
}

codevs1387的更多相关文章

随机推荐

  1. PHP学习笔记三

    <?php $a=56; $b=++$a; //等价于 $a=$a+1; $b=$a; /////2. $e=false||true;//结果为true $f=false or true;//输 ...

  2. Spring 入门 AOP

    通过一个小例子演视怎么使用 Spring 现实面向切面编程. 导入 Spring 所需要的包 spring-framework-2.5.6 版需要导入以下包: 1.----- spring.jar 2 ...

  3. quick-x 2.2.5 DragonBones 某些fla导出使用后player卡死

    1 2 3 4 5 6 7 8 9 10 11     --test 龙骨   self._db = dragonbones.new({             skeleton="game ...

  4. Sql Server 2012启动存储过程

    可以通过如下步骤创建 1.打开show advanced options reconfigure 2.打开scan for startup procs,使得sql server在启动时扫描需要运行的p ...

  5. Asp.net MVC razor语法参考

    Razor语法的快捷参考http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx/ 只是copy下来便于查阅! I ...

  6. BeanUtils 以及BeanUtils.populate使用

    Apache Jakarta Commons项目非常有用.我曾在许多不同的项目上或直接或间接地使用各种流行的commons组件.其中的一个强大的组件就是BeanUtils.我将说明如何使用BeanUt ...

  7. 232. Implement Queue using Stacks,225. Implement Stack using Queues

    232. Implement Queue using Stacks Total Accepted: 27024 Total Submissions: 79793 Difficulty: Easy Im ...

  8. [Effective Modern C++] Item 5. Prefer auto to explicit type declarations - 相对显式类型声明,更倾向使用auto

    条款5 相对显式类型声明,更倾向使用auto 基础知识 auto能大大方便变量的定义,可以表示仅由编译器知道的类型. template<typename It> void dwim(It ...

  9. <link>: rel, href

    Reference: http://www.w3schools.com/tags/tag_link.asp <link> Attributes: Attribute Value Descr ...

  10. Android 开发使用lambda实现< JDK8兼容

    代码精简无疑是每个程序员的目标,简短易读.java 8中的lambda表达式的使用: 4 easy steps Download and install jdk8. Add the following ...