程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> USACO Transformations

USACO Transformations

編輯:C++入門知識


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
    



    /*
        ID:qhn9992
        PROG:transform
        LANG:C++11
    */
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    
    using namespace std;
    
    const int INF=0x3f3f3f3f;
    int n;
    
    struct tu
    {
        char m[11][11];
        int t;
    }A,B;
    
    tu Rotation90(tu C)
    {
        tu X; X.t=C.t;
        for(int i=0;i


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved