輸入
有多組輸入。
每組輸入先輸入一個整數N(N <= 50),代表矩陣的大小。
接下來的N行,每行有N個整數。代表矩陣A。
再接下來的N行N個整數代表矩陣B。
輸出
如果矩陣A在旋轉一定角度后能和矩陣B完全一樣則輸出YES,否則輸出NO。
示例輸入
2
1 2
3 4
3 1
4 2
2
1 2
3 4
4 2
3 1
示例輸出
YES
NO
uj5u.com熱心網友回復:
#include <stdio.h>int main()
{
int a[52][52],b[52][52],n,i,j,t,flog;
while(scanf("%d",&n)!=EOF)
{
flog=1;
for(i=0; i<=n-1; i++)
{
for(j=0; j<=n-1; j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=0; i<=n-1; i++)
{
for(j=0; j<=n-1; j++)
{
scanf("%d",&b[i][j]);
}
}
for(i=0; i<=n-1; i++)
{
for(j=n-1,t=0; (t<=n-1)&&(j>=0); t++,j--)
{
if(a[j][i]!=b[i][t])
flog=0;
}
}
if(flog)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/87277.html
標籤:基礎類
