Pembagian Matriks
Pembagian Matriks - Tutorial Java Kali ini tentang Pembagian Matriks , Silahkan simak codingan berikut , langsung copas aja ke neetbeens , saya sarankan untuk mengetik ulang , :P
import java.io.*;class Bagi{public static void main(String[] args)throws Exception{DataInputStream dis =new DataInputStream (System.in);int i,j,k,l;int bk,ka,bb;double a[][];double b[][];double c[][];String brs_klm,matrik_a,matrik_b;String input;System.out.print("input Kolom Matrik A =");matrik_a=dis.readLine();System.out.print("input Baris Matrik B =");matrik_b=dis.readLine();System.out.print("Input Baris&Kolom Matrik C = ");brs_klm = dis.readLine();bk=Integer.parseInt(brs_klm);ka=Integer.parseInt(matrik_a);bb=Integer.parseInt(matrik_b);if(bk>ka){l=bk;}else{l=ka;}if(l<bb){l=bb;}l=l+1;a=new double[l][l];b=new double[l][l];c=new double[l][l];System.out.println("Input elemen matrik A =");for (i=0;i<bk ;i++ )for ( j=0;j<ka ;j++ ){a[i][j] = 0;System.out.print("elemen"+(i+1)+","+(j+1)+"=");input=dis.readLine();a[i][j] = Integer.parseInt(input);}System.out.println("Input elemen matrik B =");for ( i=0;i<bb ;i++ )for ( j=0;j<bk ;j++ ){b[i][j]=0;System.out.print("elemen"+(i+1)+","+(j+1)+"=");input=dis.readLine();b[i][j] = Integer.parseInt(input);}for ( i=0;i<bb ;i++ ){for ( j=0;j<bk ;j++ ){c[i][j] = 0;for ( k=0;k<ka ;k++ )c[i][j] =a[i][k] / b[k][j] ;}}System.out.println("HASIL PEMBAGIAN = ");for ( i=0;i<bk;i++ ){for ( j=0;j<bk ;j++ )System.out.print("\t"+c[i][j]);System.out.println();}}}
0 Komentar:
Posting Komentar
Berlangganan Posting Komentar [Atom]
<< Beranda