Tuesday, July 19, 2016

UVA 11349 Solution

Unknown
#include<cstdio>
using namespace std;

long long int matrix[100][100];

bool is_symmetric(int n)
{
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++)
            if (matrix[i][j]!=matrix[n-i-1][n-j-1]) return false;
    return true;
}

int main()
{
    int tc,c=1;
    scanf("%d",&tc);
    while (tc--)
    {
        int n,flag=1;
        char ch1,ch2;
        getchar();
        scanf("N = %d",&n);
        for (int i=0;i<n;i++)
            for (int j=0;j<n;j++)
            {
                scanf("%lld",&matrix[i][j]);
                if (matrix[i][j]<0) flag=0;
            }
        if (flag && is_symmetric(n)) printf("Test #%d: Symmetric.\n",c++);
        else printf("Test #%d: Non-symmetric.\n",c++);
    }
    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,