c语言 14分求教学
查看原帖
c语言 14分求教学
1803534
HZDWYZWDBLZS楼主2025/7/30 13:59

在vsisual studio测的时候没问题。。

#include<stdbool.h>
#define coor(n,x,y) ((x)+(n)*(y))
int main() {
    int n;
    scanf("%d", &n);
    int res = 7;
    char a[101];
    char b[101];
    for (int i = 0; i < n; i++) {
        getchar();
        for (int j = 0; j < n; j++) {
            a[coor(n, j, i)] = getchar();
        }
    }
    for (int i = 0; i < n; i++) {
        getchar();
        for (int j = 0; j < n; j++) {
            b[coor(n, j, i)] = getchar();
        }
    }

    bool Isok = true;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[coor(n, j, i)] != b[coor(n, n -i - 1, j)]) {
                Isok = false;
                break;
            }
        }
    }
    if (Isok) {
        res = 1;
    }
    if (!Isok) {
        Isok = true;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (a[coor(n, j, i)] != b[coor(n, n - j - 1, n - i - 1)]) {
                    Isok = false;
                    break;
                }
            }
        }
        if (Isok) {
            res = 2;
        }
    }
    if (!Isok) {
        Isok = true;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (a[coor(n, j, i)] != b[coor(n, i, n - j - 1)]) {
                    Isok = false;
                    break;
                }
            }
        }
        if (Isok) {
            res = 3;
        }
    }
    if (!Isok) {
        Isok = true;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= n / 2; j++) {
                if (a[coor(n, j, i)] != b[coor(n, n-j-1,i)]) {
                    Isok = false;
                    break;
                }
            }
        }
        if (Isok) {
            res = 4;
        }
    }

    if (!Isok) {
        Isok = true;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (a[coor(n, j, i)] != b[coor(n, n - i - 1, n - j - 1)]) {
                    Isok = false;
                    break;
                }
            }
        }
        if (!Isok) {
            Isok = true;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (a[coor(n, j, i)] != b[coor(n, j, n - i - 1)]) {
                        Isok = false;
                        break;
                    }
                }
            }
        }
        if (!Isok) {
            Isok = true;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (a[coor(n, j, i)] != b[coor(n, i, j)]) {
                        Isok = false;
                        break;
                    }
                }
            }
        }
        if (Isok) {
            res = 5;
        }
    }
    if (!Isok) {
        Isok = true;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (a[coor(n, j, i)] != b[coor(n, j, i)]) {
                    Isok = false;
                    break;
                }
            }
        }
        if (Isok) {
            res = 6;
        }
    }
    if (!Isok) {
        res = 7;
    }
    printf("%d", res);
    
    return 0;
}```
2025/7/30 13:59
加载中...