elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: (TUTORIAL) Aprende a emular Sentinel Dongle By Yapis


  Mostrar Temas
Páginas: [1]
1  Programación / Java / ayuda en: 3 Mayo 2010, 05:32 am
Escribir una aplicación llamado AplicacionMatriz2 que pida dos números M y N y que después pida los elementos de una matriz de M renglones por N columnas, y que a partir de esta genere y despliegue otra matriz de N renglones por M columnas, donde cada elemento de la nueva matriz estará al revés que en la matriz original. La aplicación debe funcionar como se ve en la gráfica:

matriz original

1 2 3 4
5 6 7 8
9 10 11 12

matriz al reves

12 11 10
9    8    7
6    5    4
3    2    1

esto es lo que tengo no se que hacer


import java.io.*;

public class AplicacionMatriz2 {

    public static void main(String[] args) throws IOException {

        // definiendo un objeto de entrada para tomar datos del teclado
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Da Cuantos Reglones: ");
        int m = Integer.parseInt(in.readLine());
        System.out.print("Da Cuantas Columnas: ");
        int n = Integer.parseInt(in.readLine());
        int a[][] = new int[m][n];
        int b[][] = new int [n][m] ;
       
        // pidiendo los datos del teclado de la matriz m
        System.out.println("Pidiendo Valores Matriz A");

        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < a[0].length; j++) {
                System.out.print("Da elemento " + (i + 1) + " , " + (j + 1) + " : ");
                a[j] = Integer.parseInt(in.readLine());
            }
            System.out.println();
        }

        //desplegando la matriz a

        System.out.println("Matriz Original");
        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < a[0].length; j++) {
                System.out.print(" " + a[j] + " ");
            }
            System.out.println();
        }
        System.out.println();

        System.out.println("Matriz Original");
        for (int i = 0; i < b.length; i++) {
            for (int j = 0; j < b[0].length; j++) {
                b[j]=b[a.length-i-i][a.length-i-j];
                System.out.print(" " + b[j] + " ");
            }
            //System.out.println();
        }
        //System.out.println();
       
    }
}
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines