0% found this document useful (0 votes)
12 views4 pages

New Microsoft Word Document

Uploaded by

treestylecare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

New Microsoft Word Document

Uploaded by

treestylecare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

import java.util.

*;

public class Matrix4

public static void main()

int i,j,max=0,min=0,temp,m,n,c=0;

Scanner sc=new Scanner(System.in);

System.out.println("Enter The No.Of Columns And Rows");

m=sc.nextInt();

n=sc.nextInt();

if(m<=2||n<=2||m>=20||n>=20)

System.out.println("SIZE OUT OF RANGE");

else

int a[][]=new int[m][n];

int arr[]=new int[(m*n)];

System.out.println("Enter The Array Elements");

for(i=0;i<m;i++)

for(j=0;j<n;j++)

a[i][j]=sc.nextInt();

arr[c++]=a[i][j];

max=a[0][0];

min=a[0][0];

for(i=0;i<m;i++)

for(j=0;j<n;j++)

{
if(max<a[i][j])

max=a[i][j];

if(min>a[i][j])

min=a[i][j];

System.out.println("ORIGINAL MATRIX :" +"\t");

for(i=0;i<m;i++)

for(j=0;j<n;j++)

System.out.print(a[i][j]+" ");

System.out.println();

c=1;

System.out.println("LARGEST NUMBER :"+ max);

for(i=0;i<m;i++)

for(j=0;j<n;j++)

if(max==a[i][j])

System.out.println("ROW("+c+"):"+ i);

System.out.println("COLUMN("+c+"):"+ j);

c++;

c=1;

System.out.println("SMALLEST NUMBER :"+ min);

for(i=0;i<m;i++)

{
for(j=0;j<n;j++)

if(min==a[i][j])

System.out.println("ROW("+c+"):"+ i);

System.out.println("COLUMN("+c+"):"+ j);

c++;

for(i=0;i<((m*n)-1);i++)

for(j=0;j<((m*n)-1);j++)

if(arr[j]>arr[j+1])

temp=arr[j+1];

arr[j+1]=arr[j];

arr[j]=temp;

System.out.println("REARRANGED MATRIX :");

c=0;

for(i=0;i<m;i++)

for(j=0;j<n;j++)

a[i][j]=arr[c++];

System.out.print(a[i][j]+"\t");

System.out.println();

}
}

You might also like