萌新求助 | WA*1
查看原帖
萌新求助 | WA*1
470638
Steven_lzx楼主2021/7/4 21:21

代码如下

#include<iostream>
using namespace std;
int n;
char a[15][15],b[15][15],c[15][15],d[15][15];
bool check_work1()
{
    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(b[i][j]^c[i][j])
    		{
    			return false;
    		}
    	}
    }
    return true;
}
bool check_work2()
{
    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(b[i][j]^c[i][j])
    		{
    			return false;
    		}
    	}
    }
    return true;
}
bool check_work3()
{
	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(b[i][j]^c[i][j])
    		{
    			return false;
    		}
    	}
    }
     return true;
}
bool check_work4()
{
	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(b[i][j]^c[i][j])
     		{
     			return false;
     		}
    	}
    }
    return true;
}
bool check_work5()
{
	check_work4();
	for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=n;j++)
    	{
    		a[i][j]=b[i][j]; 
    	}
    } 
    if(check_work1())
    {
    	return true;
    }
    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=n;j++)
    	{
    		a[i][j]=b[i][j]; 
    	}
    } 
    if(check_work2())
    {
    	return true;
    }
    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=n;j++)
    	{
    		a[i][j]=b[i][j]; 
    	}
    } 
    if(check_work1())
    {
    	return true;
    }
    return false;
}
bool check_work6()
{
    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;
}
void work_()
{
    if(check_work1())
    {
        cout<<"1\n";
        return;
    }
    if(check_work2())
    {
        cout<<"2\n";
        return ;
    }
    if(check_work3())
    {
    	cout<<"3\n";
    	return ;
	}
	if(check_work4())
	{
		cout<<"4\n";
		return ;
	}
	if(check_work5())
	{
		cout<<"5\n";
		return;
	}
	if(check_work6())
	{
		cout<<"6\n";
		return;
	}
	cout<<"7\n";
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=n;j++)
     	{
     		cin>>a[i][j];
     		d[i][j]=a[i][j];
	 	}
    }
    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=n;j++)
    	{
    		cin>>c[i][j];
    	}
    }
    work_();
    return 0;
}

望dalao不吝赐教

2021/7/4 21:21
加载中...