Selasa, 25 Mei 2010

Listing Program matriks Determinan

Listing Program

import java.io.*;

class det {

public static void main (String[] args) throws Exception

{

BufferedReader input=new BufferedReader(new InputStreamReader(System.in));

int matriks[][]= new int [3][3];

System.out.println("===Mencari nilai Determinan Matriks ordo 3===\n");

for (int i=0; i< 3;i++)

{

for(int j=0;j< 3;j++)

{

System.out.print("Masukkan elemen ke-"+(i+1)+","+(j+1)+"= ");

matriks[i][j]=Integer.parseInt(input.readLine());

}

}

System.out.println("\n==Matriksnya==");

for (int i=0; i< 3;i++)

{

System.out.print("|");

for(int j=0;j< 3;j++)

{

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

}

System.out.print("|");

System.out.print("\n");

}

int dtm=(matriks[0][0]*matriks[1][1]*matriks[2][2])+(matriks[0][1]*matriks[1][2]*matriks[2][0])+(matriks[0][2]*matriks[1][0]*matriks[2][1])-(matriks[0][2]*matriks[1][1]*matriks[2][0])-(matriks[0][1]*matriks[1][0]*matriks[2][2])-(matriks[0][0]*matriks[1][2]*matriks[2][1]);

System.out.print("\nDeterminan Matriksnya adalah: "+dtm);

}

}

Tidak ada komentar:

Posting Komentar