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

 

 


Tema destacado: Introducción a la Factorización De Semiprimos (RSA)


  Mostrar Temas
Páginas: [1]
1  Programación / Programación General / Matriz en: 2 Febrero 2012, 22:49 pm
Hola, soy nuevo en esto y tengo el siguiente problema: necesito generar una matriz 5x5 en la que se vayan sumando los numeros que esten a un desplazamiento a su izquierda y arriba, pongo el siguiente ejemplo:
(La matriz debera generar un cuadrado de cualquier dimension)

1 1  1   1   1
1 2  3   4   5
1 3  6  10 15
1 4 10 20 35
1 5 15 35 70

Hasta ahora e conseguido lo siguiente:
00000
12345
23456
34567
45678

    int matriz[][] = new int[5][5];
    // Ponemos datos en el array
        for ( int i=1; i < 5; i++ ) {
            for ( int j=0; j < matriz.length; j++ )
            matriz[j] = i + j;
      }
    // y vemos su contenido, utilizando un bucle for
        for ( int i=0; i < 5; i++ ) {
            for ( int j=0; j < matriz.length; j++ )
                System.out.print( matriz[j] );
                System.out.println(" ");
        }
    }
}
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines