参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); scanner.nextLine(); char [][] initial = new char[n][n]; for(int i = 0; i < n; i++) { String t = scanner.nextLine(); t = t.replace(" ", ""); initial[i] = t.toCharArray(); } char [][]end = new char[n][n]; for(int i = 0; i < n; i++) { String t = scanner.nextLine(); t = t.replace(" ", ""); end[i] = t.toCharArray(); } System.out.println(compare(initial, end)); } public static int compare(char[][] a, char[][] b) { int n = a.length; if(n == 1) return 4; String aa = ""; String bb = ""; String cc = ""; String dd = ""; String ee = ""; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { aa += a[i][j]; bb += b[i][j]; cc += a[n - 1 - j][i]; dd += a[j][n - 1 -i]; ee += a[n - 1 - i][n - 1 - j]; } if(bb.equals(cc)) return 1; if(bb.equals(dd)) return 2; if(bb.equals(ee)) return 3; if(bb.equals(aa)) return 4; } return 5; } }
0.0分
5 人评分
不容易系列 (C语言代码)浏览:702 |
蛇行矩阵 (C语言代码)浏览:792 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:863 |
【金明的预算方案】 (C++代码)浏览:997 |
【计算直线的交点数】 (C语言代码)浏览:1501 |
C语言训练-亲密数 (C语言描述,反正怎么都能对)浏览:2256 |
钟神赛车 (C语言代码)浏览:665 |
输出九九乘法表 (C语言代码)浏览:1172 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:521 |
金额的中文大写浏览:3751 |