Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/12/2013, 12:20
SilverDante
 
Fecha de Ingreso: diciembre-2013
Mensajes: 36
Antigüedad: 10 años, 5 meses
Puntos: 1
Pregunta Matrices en java

Querría que el formato en que se mostrase los valores que ha tomado una matric fuese, de por ejemplo si es una 2 x 3:

2 3 8
5 7 9

Y no que me lo muestre en una sola fila, que es lo que me sucede con el código que he creado.

Código:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package eliminafilamatriz;
import java.util.*;
/**
 *
 * @author Joan
 */
public class EliminaFilaMatriz {

    /**
     * @param args the command line arguments
     */
    
    public static void main(String[] args) {
        Scanner teclado=new Scanner(System.in);
        int n=0, m=0, i, j;
        
        System.out.println("Filas que tendrá la matriz.");
        n=teclado.nextInt();
        
        System.out.println("Columnas que tendrá la matriz.");
        m=teclado.nextInt();
        
        int [][] mxn = new int[n][m];
        
            introMatriz(mxn, n, m);
            muestraMatriz(mxn, n, m);
    }
    
    public static void introMatriz(int [][]mxn, int n, int m){
        int i, j;
            for (i = 0; i < n; i++) {
            for (j = 0; j < m; j++) {
                mxn[i][j] = (int)(Math.random()*9 + 1);
                }
            }
    }
    
    public static void muestraMatriz(int [][]mxn, int n, int m){
        int i, j;
        i=n;
        j=m;
        
            for(i=0;i<mxn.length;i++) {
            for(j=0;j<mxn[i].length;j++){
                System.out.print(mxn[i][j]+" / ");
                }
            }
    }
    
}
GRACIAS.