Skew Symmetric Matrix


Submit solution

Points: 15 (partial)
Time limit: 2.0s
Memory limit: 12M

Authors:
Problem type
Allowed languages
C

Task

To check whether the given 2D array is skew symmetric.

Input

Read the size of array in one line separated by space followed by array elements in next line separated by space.

Output

Display the result in a new line.

Sample Input1

2 3

Sample output1

Not a square matrix

Sample Input2

2 2

1 1 1 1

Sample output2

Not skew symmetric

Sample Input3

3 3

0 -5 4 5 0 -1 -4 1 0

Sample output3

Skew Symmetric


Comments


  • 0
    AthulS  commented on May 10, 2023, 3:59 p.m.

    include<stdio.h>

    int main() { int a,b,j,i,x=0; scanf("%d%d",&a,&b); int mat[a][b],res[b][a]; if(a!=b) { printf("Not a square matrix"); } else { for(i=0;i<a;i++) { for(j=0;j<b;j++){ scanf("%d",&mat[i][j]); } } for(i=0;i<a;i++){ for(j=0;j<b;j++){ res[i][j]=(-1*mat[i][j]); } }

        for(i=0;i<a;i++)
        {
        for(j=0;j<b;j++)
        {
            if(res[i][j]==mat[i][j])
            {
                x=1;
                }
            else{
                x=0;
            }
            }
        }
        if(x==1)
        {
            printf("Skew Symmetric");
        }
        else
        {
            printf("Not skew symmetric");
        }
    }

    }


  • 0
    sanjay_1704  commented on May 10, 2023, 3:44 p.m.

    include<stdio.h>

    int main() { int i,j,m,n,x; scanf("%d %d",&m,&n); int mat[m][n]; if(m==n){ for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",&mat[i][j]); } } for(i=0;i<m;i++) { for(j=0;j<n;j++) { if(mat[i][j]== -mat[j][i]) { x=1; } else{ x=0; }
    } } if(x==1){ printf("Skew symmetric"); } else if(x==0){ printf("Not skew symmetric"); } } else{ printf("Not a square matrix"); }

    return 0;

    }


  • -1
    kaivalya_kancham_57  commented on May 10, 2023, 3:37 p.m.

    include <stdio.h>

    int main() { int i,j,row,col,l=0; scanf("%d%d",&row,&col); int x[row][col]; if(row==col){ for(i=0;i<row;i++){ for(j=0;j<col;j++){ scanf("%d",&x[i][j]); } } for(i=0;i<row;i++){ for(j=0;j<col;j++){ if(x[i][j] == -x[j][i]){ l++; } } } if(l==row*col){ printf("Skew Symmetric"); }else{ printf("Not skew symmetric"); } } else{ printf("Not a square matrix"); } return 0; }


  • 0
    deepak_kumar154  commented on May 10, 2023, 3:00 p.m.

    include<stdio.h>

    int main() { int a,b,c,d; scanf("%d,%d",&a,&b); int arr[a][b]; if (b!=a){ printf("it is not a square matrix"); } else{ for(c=0;c<b;c++){ for(d=0;d<a;d++){ if (arr[c][d]=arr[c+1][d+1]){ printf("it is a square matrix"); } } } } return 0; }


  • -1
    Aathityan  commented on May 10, 2023, 2:55 p.m.

    include<stdio.h>

    int main() { int i,j,sum,product,r,c; int arr[r][c];

    scanf("%d %d",&r,&c);

    if(r==c){ for(i=0;i<r;i++) { for(j=0;j<c;j++) { scanf("%d",&arr[i][j]); }

    }
    
    if(arr[i][j]==(-1)*arr[j][i]){
     printf("its skew symmetric");  
    }else{
        printf("not skew symmetric");
    }

    } else{ printf("not a square matrix" ); }

    return 0; }