Subscribe For Free Updates!

We'll not spam mate! We promise.

Koding Java Matriks Transpose

Best Rapidshare Search
package javaapplication1;


public class Main {

    public static void main(String[] args) {
      int [][]mat1 = {{6,2,2},{0,4,5}};
      int [][]mat2 = {{3,0},{5,1},{1,1}};
      int [][]mat3 = new int [2][2];
     
      System.out.println("matriks 1");
      System.out.println("6 2 2");
      System.out.println("0 4 5");

      System.out.println("matriks 2");
      System.out.println("3 0");
      System.out.println("5 1");
      System.out.println("1 1");



      System.out.println("hasil perkalian matrik 1 dan matrik 2");
      mat3[0][0] = mat1[0][0]*mat2[0][0]+mat1[0][1]*mat2[1][0]+
              mat1[0][2]*mat2[2][0];
      mat3[0][1] = mat1[0][0]*mat2[0][1]+mat1[0][1]*mat2[1][1]+
              mat1[0][2]*mat2[2][1];
      mat3[1][0] = mat1[1][0]*mat2[0][0]+mat1[1][1]*mat2[1][0]+
              mat1[1][2]*mat2[2][1];
      mat3[1][1] = mat1[1][0]*mat2[0][1]+mat1[1][1]*mat2[1][1]+
              mat1[1][2]*mat2[2][1];
      System.out.println(mat3[0][0]+" "+mat3[0][1]);
      System.out.println(mat3[1][0]+" "+mat3[1][1]);


      int [][] mat1t = new int [3][2];
      mat1t [0][0]= mat1[0][0];
      mat1t[1][0]=mat1 [1][0];
      System.out.println("transpos matrik 1");
      System.out.println(mat1[0][0]+" "+mat1[1][0]);
      System.out.println(mat1[0][2]+" "+mat1[1][1]);
      System.out.println(mat1[0][2]+" "+mat1[1][2]);


    }

}

Peringatan: jangan hanya bisa copas., mengerti Algoritmanya itu lebih penting dari pada hafal semua bahasa pemrograman java.

Socializer Widget By Blogger Yard
SOCIALIZE IT →
FOLLOW US →
SHARE IT →

0 komentar:

Post a Comment