文章
145
粉丝
217
获赞
21
访问
83.4k
还行!!!
#include <stdio.h>
#define N 10
int Rotate_matrix(int a[][N],int b[][N],int n)
{
int i,j,k = n-1,h,flag = 1,R = 1000;
//旋转0度判断
for(i = 0; i < n; i++)
for(j = 0; j < n; j++)
if(a[i][j] != b[i][j]) flag = 0;
if(flag == 1) R = R < 0 ? R : 0;
//旋转90度判断
flag = 1;
for(i = 0; i < n; i++)
{
h = 0;
for(j = 0; j < n; j++)
if(a[i][j] != b[h++][k]) flag = 0;
k--;
}
if(flag == 1) R = R < 90 ? R : 90;
//旋转180度判断
flag = 1;
k = n-1;
for(i = 0; i < n; i++)
{
h = n-1;
for(j = 0; j < n; j++)
if(a[i][j] != b[k][h--]) flag = 0;
k--;
}
if(flag == 1) R = R < 180 ? R : 180;
//旋转270度判断
flag = 1;
h = 0;
for(i = 0; i < n; i++)
{
k = n-1;
for(j = 0; j < n; j++)
if(a[i][j] != b[k--][h]) flag = 0;
h++;
}
if(flag == 1) R = R < 270 ? R : 270;
if(R != 1000) return R;
else return -1;
}
int main()
{
int n,a[N][N],b[N][N];
while(scanf("%d",&...
登录后发布评论
暂无评论,来抢沙发