71求解
查看原帖
71求解
1192776
Im_Joker楼主2023/11/27 22:16
#include<bits/stdc++.h>
using namespace std;
char a[10][10],b[10][10],c[10][10];
int n;
bool change1(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			b[j][n-i+1]=a[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(c[i][j]!=b[i][j]){
				return 0;
			}
		}
	}
	return 1;
}
bool change2(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			b[n-i+1][n-j+1]=a[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(c[i][j]!=b[i][j]){
				return 0;
			}
		}
	}
	return 1;	
}
bool change3(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			b[n-j+1][i]=a[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(c[i][j]!=b[i][j]){
				return 0;
			}
		}
	}
	return 1;	
}
bool change4(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			b[i][n-j+1]=a[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(c[i][j]!=b[i][j]){
				return 0;
			}
		}
	}
	return 1;	
}
bool change5(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			b[i][n-j+1]=a[i][j];
		}
	}
	if(change1()){
		return 1;
	}
	if(change2()){
		return 1;
	}
	if(change3()){
		return 1;
	}
	return 0;
}
bool change6(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(c[i][j]!=a[i][j]){
				return 0;
			}
		}
	}
	return 1;	
}	
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>c[i][j];
		}
	}	
	if(change1()){
		cout<<1;
	}else if(change2()){
		cout<<2;
	}else if(change3()){
		cout<<3;
	}else if(change4()){
		cout<<4;
	}else if(change5()){
		cout<<5;
	}else if(change6()){
		cout<<6;
	}else{
		cout<<7;
	}
	return 0;
}
2023/11/27 22:16
加载中...