import java.util.*;
class Matrice
{
private int[][] a;
private int row;
private int col;
public static Scanner in()
{ return new Scanner(System.in); }
public static void out(String m)
{ System.out.print(m); }
public static int readInt(String m)
{
out(m);
return in().nextInt();
}
public Matrice()
{
row=2;
col=2;
a=new int[row][col];
}
public Matrice(int row,int col)
{
this.row=row;
this.col=col;
a=new int[row][col];
}
public void getMatrice(int row,int col,int[][] a)
{
int[][] b=new int[row][col];
for(int i=0;i<row;i++)
for(int j=0;j<col;j++)
{
b[i][j]=readInt("Enter A["+i+","+j+"]: ");
}
}
public void displayMatrice()
{
for(int k[]:a)
{
for(int p:k)
out(p+" ");
out("\n");
}
}
public void sumInRow(int row,int col)
{
int[] s=new int[row];
for(int i=0;i<row;i++)
{
s[i]=a[i][0];
for(int j=0;j<col;j++)
s[i]+=a[i][j];
}
for(int k:s)
out(k+"");
}
public void sortInRow(int row,int col,int[][] a)
{
for(int i=0;i<row;i++)
{
for(int j=0;j<col-1;j++)
for(int k=j+1;k<col;k++)
if(a[i][j]>a[i][k])
{
int t=a[i][j];
a[i][j]=a[i][k];
a[i][k]=t;
}
}
}
public void sortInColumn(int row,int col,int[][] a)
{
for(int j=0;j<col;j++)
{
for(int i=0;i<row-1;i++)
for(int k=i+1;k<row;k++)
if(a[i][j]>a[k][j])
{
int t=a[i][j];
a[i][j]=a[k][j];
a[k][j]=t;
}
}
}
public void updateElement(int row,int col,int item,int nrow,int ncol)
{
if(nrow<0 | nrow>row) return;
if(ncol<0 | ncol>col) return;
a[nrow][ncol]=item;
}
}
class Test
{
public static void main(String[] args)
{
Matrice ob=new Matrice();
int[][] a=new int[3][3];
ob.getMatrice(3,3);
ob.displayMatrice();
}
}
sotvisal -4 Newbie Poster
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
sotvisal -4 Newbie Poster
peter_budo commented: You been asked to use code tags nice way, but you wouldn't listen. Bad -4
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.