Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class symmetric
- {
- public static void main(String[] args)
- {
- int i,j,n,m;
- System.out.println("Enter the number of rows and columns of the Matrix");
- Scanner t=new Scanner(System.in);
- n=t.nextInt();
- m=t.nextInt();
- int a[][]= new int[n][m];
- System.out.println("Enter the elements of the matrix");
- for(i=0;i<n;++i)
- {
- for(j=0;j<m;++j)
- a[i][j]=t.nextInt();
- }
- System.out.println("Entered matrix");
- for(i=0;i<n;++i)
- {
- for(j=0;j<m;++j)
- System.out.print(a[i][j] + "\t");
- System.out.println();
- }
- int flag=1;
- for(i=0;i<n;++i)
- {
- for(j=0;j<m;++j)
- {
- if(a[i][j]==a[j][i])
- continue;
- else
- {
- flag = 0;
- break;
- }
- }
- }
- if(flag==0)
- System.out.println("Matrix is not symmetric");
- else
- System.out.println("Matrix is symmetric");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement