1.2.2Transformations

  
    
  1. /*
  2. ID: awsd1231
  3. PROG: transform
  4. LANG: C++
  5. */
  6. #include<iostream>
  7. #include<cstdio>
  8. using namespace std;
  9. char square[15][15], afterSquare[15][15], tmpSquare[15][15];
  10. int n;
  11. bool num1() {
  12. for(int i = 0; i != n; ++i) {
  13. for(int j = 0; j != n; ++j) {
  14. if(tmpSquare[n-j-1][i] != afterSquare[i][j])
  15. return false;
  16. }
  17. }
  18. return true;
  19. }
  20. bool num2() {
  21. for(int i = 0; i != n; ++i) {
  22. for(int j = 0; j != n; ++j) {
  23. if(tmpSquare[n-i-1][n-j-1] != afterSquare[i][j])
  24. return false;
  25. }
  26. }
  27. return true;
  28. }
  29. bool num3() {
  30. for(int i = 0; i != n; ++i) {
  31. for(int j = 0; j != n; ++j) {
  32. if(tmpSquare[n-j-1][i] != afterSquare[i][j])
  33. return false;
  34. }
  35. }
  36. return true;
  37. }
  38. bool num4() {
  39. for(int i = 0; i != n; ++i) {
  40. for(int j = 0; j != n; ++j) {
  41. if(tmpSquare[i][n-j-1] != afterSquare[i][j])
  42. return false;
  43. }
  44. }
  45. return true;
  46. }
  47. bool num5() {
  48. for(int i = 0; i != n; ++i) {
  49. for(int j = 0; j != n; ++j) {
  50. tmpSquare[i][j] = square[i][n-1-j];
  51. }
  52. }
  53. if(num1()) return true;
  54. if(num2()) return true;
  55. if(num3()) return true;
  56. for(int i = 0; i != n; ++i) {
  57. for(int j = 0; j != n; ++j) {
  58. tmpSquare[i][j] = square[i][j];
  59. }
  60. }
  61. return false;
  62. }
  63. bool num6() {
  64. for(int i = 0; i != n; ++i) {
  65. for(int j = 0; j != n; ++j) {
  66. if(tmpSquare[i][j] != afterSquare[i][j])
  67. return false;
  68. }
  69. }
  70. return true;
  71. }
  72. int main() {
  73. freopen("transform.in", "r", stdin);
  74. freopen("transform.out", "w", stdout);
  75. cin >> n;
  76. for(int i = 0; i != n; ++i)
  77. for(int j = 0; j != n; ++j) {
  78. cin >> square[i][j];
  79. tmpSquare[i][j] = square[i][j];
  80. }
  81. for(int i = 0; i != n; ++i)
  82. for(int j = 0; j != n; ++j)
  83. cin >> afterSquare[i][j];
  84. if(num1()) {
  85. cout << "1" << endl;
  86. return 0;
  87. }
  88. if(num2()) {
  89. cout << "2" << endl;
  90. return 0;
  91. }
  92. if(num3()) {
  93. cout << "3" << endl;
  94. return 0;
  95. }
  96. if(num4()) {
  97. cout << "4" << endl;
  98. return 0;
  99. }
  100. if(num5()) {
  101. cout << "5" << endl;
  102. return 0;
  103. }
  104. if(num6()) {
  105. cout << "6" << endl;
  106. return 0;
  107. }
  108. cout << "7" << endl;
  109. return 0;
  110. }





你可能感兴趣的:(transform)