34分求助
查看原帖
34分求助
553255
遇事不决就选C楼主2022/10/8 22:36
#include <bits/stdc++.h>
using namespace std;
char a[15][15], b[15][15], c[15][15];
int n;
void first() {
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			c[j][n - i + 1] = a[i][j];
		}
	}
}
void fourth(){
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            c[i][n - j + 1] = a[i][j];
        }
    }
}
void resets(){
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            c[i][j] = a[i][j];
        }
    }
}
bool chk(){
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(b[i][j] != c[i][j]) return false;
        }
    }
    return true;
}
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> a[i][j];
			c[i][j] = a[i][j];
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) cin >> b[i][j];
	}
	if (chk()) {
		cout << 6;
		return 0;
	}
	first();
	if (chk()) {
		cout << 1;
		return 0;
	}
	resets();
	first();
	first();
	if (chk()) {
		cout << 2;
		return 0;
	}
	resets();
	first();
	first();
	first();
	if (chk()) {
		cout << 3;
		return 0;
	}
	fourth();
	if (chk()) {
		cout << 4;
		return 0;
	}
	fourth();
	first();
	if (chk()) {
		cout << 5;
		return 0;
	}
	resets();
	fourth();
	first();
	first();
	if (chk()) {
		cout << 5;
		return 0;
	}
	resets();
	fourth();
	first();
	first();
	first();
	if (chk()) {
		cout << 5;
		return 0;
	}
	cout << 7;
	return 0;
}
2022/10/8 22:36
加载中...