“cara mencetak matriks di java” Kode Jawaban

cara mencetak matriks di java

for (int row = 0; row < arr.length; row++)//Cycles through rows
{
  for (int col = 0; col < arr[row].length; col++)//Cycles through columns
  {
    System.out.printf("%5d", arr[row][col]); //change the %5d to however much space you want
  }
  System.out.println(); //Makes a new row
}
//This allows you to print the array as matrix
GelatinousMustard

Cetak Array 2D di Java

int[][] array = new int[rows][columns];
System.out.println(Arrays.deepToString(array));
Careful Cockroach

cara mencetak elemen dalam matriks java

public static void printMatrix(Object[][] matrix){
        for (int i = 0; i < matrix.lenght ; i++) {
            for (int j = 0; j < matrix.lenght; j++) {
                System.out.print(matrix[i][j] + " ");
            }
            System.out.println();
        }
    }
DoubleBaconCheeseBurguer

cara pintar untuk mencetak matriks di java

//first method::
for(int i=0;i<n;i++)
  	System.out.println(Arrays.toString(matrix[i]));

//second method::

java.util.stream.IntSteam
  				.range(0,n)
  				.forEach(i->System.out.println(Arrays.toString(matrix[i])));

//code by dungriyal
Defeated Devil

Jawaban yang mirip dengan “cara mencetak matriks di java”

Pertanyaan yang mirip dengan “cara mencetak matriks di java”

Lebih banyak jawaban terkait untuk “cara mencetak matriks di java” di Java

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya