题解 | #矩阵相等判定#

矩阵相等判定

http://www.nowcoder.com/practice/2f058b1e89ae43f7ab650c0fd0b71fa8

#include<stdio.h>
int main()
{

    int arr[][10] = { 0 };
    int n, m, i, j;
     int a = 0;
     int b = 0;
    int sum = 0;
    scanf("%d%d", &n, &m);
    for (i = 0; i<n; i++)
    {
        for (j = 0; j<m; j++)
        {
            printf("1####");
            scanf("%d", &arr[i][j]);

        }
    }

    for (a = 0; a <n; a++)
    {
        for (b = 0; b <m; b++)
        {
            printf("2#####");
            scanf("%d", &arr[a][b]);
            for (int c = 0; c < i; c++)
            {
                for (int d = 0; d < j; d++)
                {
                    if (arr[c][d] == arr[a][b])
                   {
                     sum++;
                   }
                }

            }
        }
    }
    if (sum == (n*m))
    {
        printf("yes");
    }
    else
    {
        printf("no");
    }
    return 0;
}
全部评论

相关推荐

2 收藏 评论
分享
牛客网
牛客企业服务