Palembang, 24 Mei 2012 05:00
import java.io.*;
class Matriks {
public static void main(String args[]) {
int[][] M = new int[3][4];
int i,j;
//input matriks
BufferedReader isi;
System.out.println("Input Elemen Matriks M[3][4]");
try {
isi = new BufferedReader(new InputStreamReader(System.in));
for(i=0; i<3; i++) {
for(j=0; j<4; j++) {
System.out.print("M["+i+"]["+j+"] = ");
M[i][j] = new Integer(isi.readLine()).intValue();
}
System.out.println("\n");
}
} catch (Exception e ){
System.out.println("Input berupa integer aja");
}
//tampilkan isi matriks
System.out.println("Isi Matriks M");
for(i=0; i<3; i++) {
for(j=0; j<4; j++) {
System.out.print(M[i][j]+" ");
}
System.out.println("");
}
}
}
Tidak ada komentar:
Posting Komentar