Ir ao conteúdo
  • Cadastre-se

Validar Matriz com has


Posts recomendados

Eu tenho o código de uma matriz transposta e gostaria de saber como eu validaria utilizando um hash de divisão.

 

public static void main(String[] args) {
        Scanner ler = new Scanner(System.in);

        int MatrizA[][] = new int[3][3];
        int MatrizB[][] = new int[3][3];
        double MatrizC[][] = new double[3][3];

        //Construção da matriz
        for (int i = 0; i < MatrizA.length; i++) {
            System.out.printf("Informe os elementos da %da. linha:\n", (i + 1));
            for (int j = 0; j < MatrizA.length; j++) {
                System.out.printf("a[%d][%d] = ", i, j);
                MatrizA[j] = ler.nextInt();
            }
            System.out.printf("\n");
        }
        for (int i = 0; i < MatrizA.length; i++) {
            for (int j = 0; j < MatrizA.length; j++) {
                MatrizB[j] = MatrizA[j];
            }
        }
        System.out.printf("\nMatriz Original\n");
        for (int i = 0; i < MatrizA.length; i++) {
            System.out.printf("%da. linha: ", (i + 1));
            for (int j = 0; j < MatrizA.length; j++) {
                System.out.printf("%d ", MatrizA[j]);
            }
            System.out.printf("\n");
        }

        //Matriz Transposta
        System.out.printf("\nMatriz Transposta\n");
        for (int i = 0; i < MatrizB.length; i++) {
            System.out.printf("%da. linha: ", (i + 1));
            for (int j = 0; j < MatrizB.length; j++) {
                System.out.printf("%d ", MatrizB[j]);
            }
            System.out.printf("\n");
        }
    

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...