题目:

Transformations

A square pattern of size N x N (1 <= N <= 10) black and white square tiles is transformed into another square pattern. Write a program that will recognize the minimum transformation that has been applied to the original pattern given the following list of possible transformations:

  • #1: 90 Degree Rotation: The pattern was rotated clockwise 90 degrees.
  • #2: 180 Degree Rotation: The pattern was rotated clockwise 180 degrees.
  • #3: 270 Degree Rotation: The pattern was rotated clockwise 270 degrees.
  • #4: Reflection: The pattern was reflected horizontally (turned into a mirror image of itself by reflecting around a vertical line in the middle of the image).
  • #5: Combination: The pattern was reflected horizontally and then subjected to one of the rotations (#1-#3).
  • #6: No Change: The original pattern was not changed.
  • #7: Invalid Transformation: The new pattern was not obtained by any of the above methods.

In the case that more than one transform could have been used, choose the one with the minimum number above.

PROGRAM NAME: transform

INPUT FORMAT

Line 1: A single integer, N
Line 2..N+1: N lines of N characters (each either `@' or `-'); this is the square before transformation
Line N+2..2*N+1: N lines of N characters (each either `@' or `-'); this is the square after transformation

SAMPLE INPUT (file transform.in)

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

OUTPUT FORMAT

A single line containing the the number from 1 through 7 (described above) that categorizes the transformation required to change from the `before' representation to the `after' representation.

SAMPLE OUTPUT (file transform.out)

1

题目其实很简单,第一遍看题时想复杂了( 我想的是经过一系列变化,而题目要求只是其中某一次变化,后来仔细看输出只要一个数字,才改正确 )题意是说有七种变化方式,1,顺指针90度,2,180度,3,270度,4,镜面,5,镜面后按1--3转,6,不变,7,1--6都搞不定。最初用函数写,方式到很简单,不知道为何在引用函数式出问题了,一气之下就全部删掉,然后全部弄到main里面。结果初始化flag时又有点想当然,认为会自动为1,结果又错了几次。代码:
/*
ID:614433244
PROG: transform
LANG: C++*/
#include"iostream"
#include"cstdio"
#include"cstring"
using namespace std;
char a[11][11],b[11][11],c[11][11];
int n;
int main()
{freopen("transform.in","r",stdin);freopen("transform.out","w",stdout);cin>>n;int i,j;for( i=1;i<=n;i++ )for( j=1;j<=n;j++ ){cin>>a[i][j];c[i][n+1-j]=a[i][j];}for( i=1;i<=n;i++ )for( j=1;j<=n;j++ )cin>>b[i][j];int temp=7;bool flag;if( temp==7 )//90度
    {flag=1;for( i=1;i<=n;i++ ){for( j=1;j<=n;j++ )if( a[i][j]!=b[j][n+1-i] ){flag=0;break;}if( !flag )break;}if( flag )temp=1;}if( temp==7 )//180度
    {flag=1;for( i=1;i<=n;i++ ){for( j=1;j<=n;j++ )if( a[i][j]!=b[n+1-i][n+1-j] ){flag=0;break;}if( !flag )break;}if( flag )temp=2;}if( temp==7 )//270度
    {flag=1;for( i=1;i<=n;i++ ){for( j=1;j<=n;j++ )if( a[i][j]!=b[n+1-j][i] ){flag=0;break;}if( !flag )break;}if( flag )temp=3;}if( temp==7 )//镜面
    {flag=1;for( i=1;i<=n;i++ ){for( j=1;j<=n;j++ )if( c[i][j]!=b[i][j] ){flag=0;break;}if( !flag )break;}if( flag )temp=4;}//    if( temp==7 )//第五种
//    {if( temp==7 )//90度
        {flag=1;for( i=1;i<=n;i++ ){for( j=1;j<=n;j++ )if( c[i][j]!=b[j][n+1-i] ){flag=0;break;}if( !flag )break;}if( flag )temp=5;}if( temp==7 )//180度
        {flag=1;for( i=1;i<=n;i++ ){for( j=1;j<=n;j++ )if( c[i][j]!=b[n+1-i][n+1-j] ){flag=0;break;}if( !flag )break;}if( flag )temp=5;}if( temp==7 )//270度
        {flag=1;for( i=1;i<=n;i++ ){for( j=1;j<=n;j++ )if( c[i][j]!=b[n+1-j][i] ){flag=0;break;}if( !flag )break;}if( flag )temp=5;}//    }if( temp==7 ){flag=1;for( i=1;i<=n;i++ ){for( j=1;j<=n;j++ )if( a[i][j]!=b[i][j] ){flag=0;break;}if( !flag )break;}if( flag )temp=6;}
/*
for( i=1;i<=n;i++ )
{for( j=1;j<=n;j++ )cout<<a[i][j];cout<<endl;
}
cout<<endl;
for( i=1;i<=n;i++ )
{for( j=1;j<=n;j++ )cout<<c[i][j];cout<<endl;
}
cout<<endl;
for( i=1;i<=n;i++ )
{for( j=1;j<=n;j++ )cout<<b[i][j];cout<<endl;
}
cout<<endl;
*/printf("%d\n",temp);return 0;
}

转载于:https://www.cnblogs.com/rolyxiao/archive/2012/06/02/2531953.html

usaco1.2.2 transform相关推荐

  1. 洛谷 P1218 [USACO1.5]特殊的质数肋骨 Superprime Rib

    P1218 [USACO1.5]特殊的质数肋骨 Superprime Rib 题目描述 农民约翰的母牛总是产生最好的肋骨.你能通过农民约翰和美国农业部标记在每根肋骨上的数字认出它们.农民约翰确定他卖给 ...

  2. css3之transition、transform、animation比较

    css3动画多少都有些了解,但是对于transition.transform.animation这几个属性一直是比较模糊的,所以啊,这里做一个总结,也希望大家都可以对此有一个更好地理解.    其实, ...

  3. 基于css3 transform实现散乱的照片排列

    分享一款基于css3 transform实现散乱的照片排列.这是一款简单零散的css3相册排列特效下载.效果图如下: 在线预览    源码下载 实现的代码. html代码: <div class ...

  4. OpenCV中的尺度不变特征变换(SIFT Scale-Invariant Feature Transform)

    OpenCV中的尺度不变特征变换(SIFT Scale-Invariant Feature Transform) 1. 效果图 2. 原理 2.1 步骤 2.2 opencv实现方法 2.3 SIFT ...

  5. FT(Fourier Transform)在滤波上的应用

    数学真的是一个神奇的科学,美妙之处无法言语形容. 傅里叶变换的推导见博客: 对于非周期的函数就是周期T趋于0,将一般非周期的函数写作傅里叶级数的形式: 其中:就是FT(Fourier Transfor ...

  6. transform总结

    1. 用jquery的css方法获取transform得到的是矩阵matrix,不利于获取translate的值, 优先使用dom.style.webKitTransform进行transform的读 ...

  7. 放大 旋转 css3,CSS3详解:transform 的旋转、旋转放大、放大、移动

    CSS3 transform是什么? transform的含义是:改变,使-变形:转换 CSS3 transform都有哪些常用属性? transform的属性包括:rotate() / skew() ...

  8. std::transform使用

    std::transform在指定的范围内应用于给定的操作,并将结果存储在指定的另一个范围内. 以下是std::transform的两个声明,一个是对应于一元操作,一个是对应于二元操作 templat ...

  9. C++ transform for_each

    #include<iostream> #include<vector> #include <list> #include <algorithm> #in ...

最新文章

  1. Jmeter之完整的HTTP接口测试
  2. Linux环境下MySQL基础命令(3)----增、删、改、查语句
  3. php实现电脑自动关机,用批处理实现电脑自动关机
  4. 基于JAVA+SpringBoot+Mybatis+MYSQL的文档管理系统
  5. 帝国cms熊掌号MIP主动推送教程
  6. Mysql基础之 事务
  7. android eventbus view,Android-EventBus框架详细介绍与简单实现
  8. html pie标签,pie.html
  9. 1200,1500PLC通过将FB284封装成一个标准FB块控制V90PN伺服EPOS定位
  10. 音视频 即时通讯Linux源码
  11. 中山一院:华南第一综合性三甲医院的 IT 基础架构转型实践
  12. macbook linux 双系统,Mac双系统切换及设置技巧
  13. html5中span作用,span标签的作用与用法总结
  14. JDK19都出来了~是时候梳理清楚JDK的各个版本的特性了【JDK15特性讲解】
  15. 会计专业计算机工具,会计工作需要用哪些工具
  16. 第2.1章 scrapy之国内高匿代理IP爬取
  17. SQL SERVER2000 如何打开.MDF、.LDF文件
  18. 干货福利分享:pdf怎么去水印 如何在线去除PDF水印
  19. modbustcp测试工具怎么用_【转】年轻人不讲武德不仅白piao接口测试知识还白piao接口测试工具会员...
  20. php5编译安装常见错误和解决办法集锦

热门文章

  1. 微信小程序rpx作为高度单位时,在 ios 出现异常
  2. 【若依(ruoyi)】树表代码生成
  3. c语言输入字符串的格式不正确的是,关于c#:输入字符串的格式不正确
  4. 怎么在pycharm打开浏览器_Mac OS下搭建 python3+pycharm+selenium+Chrome环境
  5. 正式发布python版本的年份_飞书首次举办产品发布会,新版本“”正式发布
  6. lisp 线性标注自动避让_CAD局部放大图如何标注对应的尺寸,才能保持尺寸值不变...
  7. 十七、Pytorch的安装和使用
  8. 人人都能学会的 Python 多线程指南!
  9. 就有趣,Python生成字符视频
  10. 全球IPv4地址正式耗尽,你知道吗?