《c语言程序设计》习题.判断偶数矩阵

#include 
#define N 100
void InputArray(int a[N][N], int n, int m);
void Judge(int a[N][N], int n, int m);
int main()
{
    int a[N][N];
    int n, m;
    scanf("%d%d", &n, &m);
    InputArray(a, n, m);
    Judge(a, n, m);
}
void InputArray(int a[N][N], int n, int m)
{
    int i, j;
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            scanf("%d", &a[i][j]);
            /* code */
        }
        /* code */
    }
}
void Judge(int a[N][N], int n, int m)
{
    int i, j, sum, count = 0, flag = 0;
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            sum += a[i][j];
            count++;
            if (count == m)
            {
                if (sum % 2 == 0)
                {
                    flag = 1;
                    /* code */
                }
                /* code */
            }
            /* code */
        }
        /* code */
    }
    sum = count = 0;
    if (flag == 1)
    {
        for (j = 0; j < m; j++)
        {
            for (i = 0; i < n; i++)
            {
                sum += a[i][j];
                count++;
                if (count == n)
                {
                    if (sum % 2 == 0)
                    {
                        flag = 2;
                        /* code */
                    }
                    /* code */
                }

                /* code */
            }
            /* code */
        }
        /* code */
    }
    if (flag == 2)
    {
        printf("Yes");
        /* code */
    }
    else
    {
        printf("No");
    }
}

你可能感兴趣的:(c语言,c语言)