Transpose Matrix di Java

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package transposematrix;

/**
*
* @author ANGGA Kireina
*/
public class transposeMatrix {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println(“Transpose :”);
int baris;
int kolom;

int [][] Matrix;
Matrix = new int[3][3];

for(baris=0; baris<2; baris++){
for(kolom=0; kolom<3; kolom++){
Matrix [baris][kolom] = 10;
System.out.print(Matrix[baris][kolom]+" ");
}
System.out.println(""); // pindah baris
}

System.out.println("");

for(baris=0; baris<3; baris++){
for(kolom=0; kolom<2; kolom++){
Matrix [baris][kolom] = 10;
System.out.print(Matrix[kolom][baris]+" ");
}
System.out.println("");
}

}
}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s