import java.io.*;
class test
{
public static void main(String[] asd)throws IOException
{
BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the values of Rows and Columns of Matrix.");
String num=obj.readLine();
int r=Integer.parseInt(num);
num=obj.readLine();
int c=Integer.parseInt(num);
int m[][]= new int[r][c];
int max=0, min=0;
System.out.println("Enter the values of the matrix not more then "+(r*c)+".");
for(int i=0;i<r;i++)
for(int j=0;j<c;j++)
{
num=obj.readLine();
m[i][j]=Integer.parseInt(num);
}
System.out.println("Original matrix::");
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
System.out.print(m[i][j]+" ");
}
System.out.println();
}
// MAXIMUM element of the matrix max=m[0][0];
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
if(m[i][j]>max) max=m[i][j];
}
}
System.out.println("Maximum of the matrix is "+max+".");
//MINIMUM element of the matrix min=m[0][0];
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
if(m[i][j]<min) min=m[i][j];
}
}
System.out.println("Minimum of the matrix is "+min+".");
}
}
class test
{
public static void main(String[] asd)throws IOException
{
BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the values of Rows and Columns of Matrix.");
String num=obj.readLine();
int r=Integer.parseInt(num);
num=obj.readLine();
int c=Integer.parseInt(num);
int m[][]= new int[r][c];
int max=0, min=0;
System.out.println("Enter the values of the matrix not more then "+(r*c)+".");
for(int i=0;i<r;i++)
for(int j=0;j<c;j++)
{
num=obj.readLine();
m[i][j]=Integer.parseInt(num);
}
System.out.println("Original matrix::");
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
System.out.print(m[i][j]+" ");
}
System.out.println();
}
// MAXIMUM element of the matrix max=m[0][0];
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
if(m[i][j]>max) max=m[i][j];
}
}
System.out.println("Maximum of the matrix is "+max+".");
//MINIMUM element of the matrix min=m[0][0];
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
if(m[i][j]<min) min=m[i][j];
}
}
System.out.println("Minimum of the matrix is "+min+".");
}
}
No comments:
Post a Comment