Created
April 12, 2012 05:06
-
-
Save ngnguyen1/2364709 to your computer and use it in GitHub Desktop.
Ma Trận
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************** | |
Java Programing Language | |
Author: nduy.nga | |
******************************/ | |
package mTran; | |
//import java.; | |
public class MaTran | |
{ | |
private int row,col; | |
int MT[][]; | |
public MaTran() | |
{ | |
} | |
public MaTran(int n,int m) | |
{ | |
row=n; | |
col=m; | |
MT=new int[row][col]; | |
} | |
public void NhapMT() | |
{ | |
do{ | |
System.out.print("Nhap so dong: ");this.row=NhapDL.nhapInt(); | |
System.out.print("Nhap so cot : ");this.col=NhapDL.nhapInt(); | |
}while(((row<1)||(col<1))); | |
System.out.println("Nhap DL cho ma tran " +row+"x"+col); | |
MT=new int[row][col]; | |
for(int i=0;i<row;i++) | |
for(int j=0;j<col;j++) | |
{ | |
System.out.print("Nhap ["+(i+1)+","+(j+1)+"]= "); | |
MT[i][j]=NhapDL.nhapInt(); | |
} | |
} | |
public void inMaTran() | |
{ | |
System.out.println("Ma Tran vua nhap la: "); | |
for(int i=0;i<row;i++) | |
{ | |
for(int j=0;j<col;j++) | |
System.out.print(MT[i][j]+" "); | |
System.out.println(); | |
} | |
} | |
public void max() | |
{ | |
int max = MT[0][0]; | |
for(int i=0;i<row;i++) | |
for (int j=0;j<col;j++) | |
if(max<MT[row][col]) max=MT[row][col]; | |
System.out.println("Phan tu lon nhat la: " +max); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment