Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.11 KB | None | 0 0
  1. /*
  2. ID: victao1
  3. LANG: C++
  4. TASK: transform
  5. */
  6. #include <iostream>
  7. #include <cstdio>
  8. #define MAX_N 10
  9. int N = MAX_N;
  10. using namespace std;
  11.  
  12. void print(char a[MAX_N][MAX_N]){
  13.     for(int i = 0; i < N; i++){
  14.         for(int j = 0; j < N; j++){
  15.             cout << a[i][j];
  16.         }
  17.         cout << "\n";
  18.     }
  19. }
  20. void reflect(char a[MAX_N][MAX_N]){
  21.     char t, newa[MAX_N][MAX_N];
  22.     int c = 0;
  23.     for(int i = 0; i < N; i++){
  24.         for(int j = 0; j < N; j++){
  25.             newa[i][N - j - 1]  = a[i][j];
  26.         }
  27.     }
  28.     for(int i = 0; i < N; i++){
  29.         for(int j = 0; j < N; j++){
  30.             a[i][j]  = newa[i][j];
  31.         }
  32.     }
  33.  
  34. }
  35. void copyarray(char a[MAX_N][MAX_N], char copya[MAX_N][MAX_N]){
  36.     for(int i = 0; i < N; i++){
  37.         for(int j = 0; j < N; j++){
  38.             copya[i][j]  = a[i][j];
  39.         }
  40.     }
  41. }
  42. bool equals(char a[MAX_N][MAX_N], char ar[MAX_N][MAX_N]){
  43.     bool b = true;
  44.     for(int i = 0; i < N; i++){
  45.         for(int j = 0; j < N; j++){
  46.             if(ar[i][j] != a[i][j]){
  47.                 b = false;
  48.                 break;
  49.             }
  50.  
  51.         }
  52.     }
  53.     return b;
  54. }
  55. void clockwise(char a[MAX_N][MAX_N]){
  56.     char t, newa[MAX_N][MAX_N];
  57.     int c = 0;
  58.     for(int i = 0; i < N; i++){
  59.         for(int j = 0; j < N; j++){
  60.             newa[j][N - i - 1]  = a[i][j];
  61.         }
  62.     }
  63.     for(int i = 0; i < N; i++){
  64.         for(int j = 0; j < N; j++){
  65.             a[i][j]  = newa[i][j];
  66.         }
  67.     }
  68.  
  69. }
  70. int main(){
  71.  
  72.     freopen("transform.in", "r", stdin);
  73.     freopen("transform.out", "w", stdout);
  74.     cin >> N;
  75.     char a[MAX_N][MAX_N], copya[MAX_N][MAX_N], out[MAX_N][MAX_N];
  76.     for(int i = 0; i < N; i++){
  77.         for(int j = 0; j < N; j++){
  78.             cin >> a[i][j];
  79.             copya[i][j] = a[i][j];
  80.         }
  81.     }
  82.     for(int i = 0; i < N; i++){
  83.         for(int j = 0; j < N; j++){
  84.             cin >> out[i][j];
  85.         }
  86.     }
  87.    //rint(out);
  88.     char one[MAX_N][MAX_N];
  89.     copyarray(a, one);
  90.     clockwise(one);
  91.     char two[MAX_N][MAX_N];
  92.     copyarray(a, two);
  93.     clockwise(two);
  94.     clockwise(two);
  95.     char three[MAX_N][MAX_N];
  96.     copyarray(a, three);
  97.     clockwise(three);
  98.     clockwise(three);
  99.     clockwise(three);
  100.     char four[MAX_N][MAX_N];
  101.     copyarray(a, four);
  102.     reflect(four);
  103.     char fivea[MAX_N][MAX_N];
  104.     copyarray(a, fivea);
  105.     reflect(fivea);
  106.     clockwise(fivea);
  107.     char fiveb[MAX_N][MAX_N];
  108.     copyarray(a, fiveb);
  109.     reflect(fiveb);
  110.     clockwise(fiveb);
  111.     clockwise(fiveb);
  112.     char fivec[MAX_N][MAX_N];
  113.     copyarray(a, fivec);
  114.     reflect(fivec);
  115.     clockwise(fivec);
  116.     clockwise(fivec);
  117.     clockwise(fivec);
  118.     if(equals(one, out)) cout << "1" << "\n"; else
  119.     //copya = a;
  120.     if(equals(two, out)) cout << "2" << "\n"; else
  121.     if(equals(three, out)) cout << "3" << "\n"; else
  122.     if(equals(four, out)) cout << "4" << "\n"; else
  123.     if(equals(fivea, out)) cout << "5" << "\n"; else
  124.     if(equals(fiveb, out)) cout << "5" << "\n"; else
  125.     if(equals(fivec, out)) cout << "5" << "\n"; else
  126.     if(equals(a, out)) cout << "6" << "\n"; else cout << "7" << "\n";
  127.  
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement