文章
79
粉丝
221
获赞
46
访问
197.9k
注:
1.多组输入数据
2.0°:a[i][j] == b[i][j]
3.90°:a[i][j] == b[j][n - i - 1]
4.180°:a[i][j] == b[n - i - 1][n - j - 1]
5.270°:a[i][j] == b[n - j - 1][i]
6.一旦在双层循环中不符合某度数的公式时,需要及时break出双层循环,因此需要设置flag用来跳出第一层循环
#include <iostream>
using namespace std;
int Sul(int** a, int** b, int n) {
int i, j, flag;
for (i = 0, flag = 0; i < n; i++) {
for (j = 0; j < n; j++)
if (a[i][j] != b[i][j]) {
flag = 1;
break;
}
if (flag == 1)
break;
}
if (flag == 0)
return 0;
for (i = 0, flag = 0; i < n; i++) {
for (j = 0; j < n; j++)
if (a[i][j] != b[j][n - i - 1]) {
flag = 1;
break;
}
if (flag == 1)
break;
}
if (flag == 0)
return 90;
for (i = 0, flag = 0; i < n; i++) {
for (j = 0; j < n; j++)
if (a[i][j] != b[n - i - 1][n - j - 1]) {
flag = 1;
break;
}
if (flag == 1)
break;
}
if (flag == 0)
return 180;
for (i = 0, flag = 0; i < n; i++...
登录后发布评论
暂无评论,来抢沙发