请看主函数的注释
用 cin 就 AC 了, scanf 只过了一个点 ?
#include <bits/stdc++.h>
using namespace std;
int n;
char a[15][15], b[15][15], c[15][15], d[15][15];
bool 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 0;
return 1;
}
bool 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 0;
return 1;
}
bool 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 0;
return 1;
}
bool 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 0;
return 1;
}
bool work5()
{
work4();
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
a[i][j] = b[i][j];
if(work1()) return 1;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
a[i][j] = b[i][j];
if(work2()) return 1;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
a[i][j] = b[i][j];
if(work3()) return 1;
return 0;
}
bool work6()
{
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
if(b[i][j] != c[i][j]) return 0;
return 1;
}
void work()
{
if(work1()) printf("1");
else if(work2()) printf("2");
else if(work3()) printf("3");
else if(work4()) printf("4");
else if(work5()) printf("5");
else if(work6()) printf("6");
else printf("7");
return ;
}
int main()
{
// scanf("%d" , &n);
cin >> n;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
{
// scanf("%s" , &a[i][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++)
// scanf("%s" , &c[i][j]);
cin >> c[i][j];
work();
return 0;
}