Código:
/*Creado por wifixcort*/
import java.util.*;
public class Inversion{
/*PARA PROBAR SOLO HACER UN METODO MAIN Y LLAMAR UNICAMENTE A CAMBIOS
AGREGUE EL METODO IMPRESION SOLO PARA VISUALIZAR MAS FACILMENTE LA
SOLUCION*/
Random ram = new Random();
int[][] mat1 = new int[4][4];//Para satisfacer el problema
int[][] mat2 = new int[4][4];//aunq es extendible a cualquer par de matrices cuadradas
//unicamente para matrices cuadradas
/*-------------Metodo para intercambiar matricess--------------------*/
public void cambios(){
llenado();
int[] array1 = new int[mat1.length];
int[] array2 = new int[mat1.length];
for(int i=0; i<mat1.length; ++i){
for(int j=0; j<mat1[0].length; ++j){
int a = mat1.length -1;
array1[j] = mat1[a-i][j];//inicia desde el final(algo raro)
array2[j] = mat2[i][j];//inicia desde el principios(lo normal)
mat2[i][j] = array1[j];//se la mete al inicio
mat1[a-i][j] = array2[j];//se la mate al fondo
}
}
impresion(mat1);
impresion(mat2);
}
/*------------------------Fin de metodo-------------------------*/
/*---------------Metodo para llenar las matices-----------------*/
public void llenado(){
for(int i=0; i<mat1.length; ++i){
for(int j=0; j<mat1.length; ++j){
mat1[i][j] = ram.nextInt(100)+1;
mat2[i][j] = ram.nextInt(100)+1;
}
}
impresion(mat1);
impresion(mat2);
}
/*------------------------Fin de metodo-------------------------*/
/*----------------Metodo para imprimir matrices-----int---------*/
public void impresion(int[][] alpha){
for(int i=0; i<alpha.length; ++i){
System.out.println("");
for(int j=0; j<alpha[0].length; ++j){
System.out.print(alpha[i][j]+" ");
}
}
System.out.println("");
}
/*----------------------Fin de metodo--------------------------*/
}
estaba leyendo y me di cuenta que tengo q aportar el siguiente ejercicio y como veo que ponen bastante de matrices les propongo este, en caso de que den el visto bueno a mi solucion anterior
Les propongo encontrar el promedio por columna de una matriz cualquiera
Mucha suerte!!!Y saludos a todos
por ultimo los felicito por esta iniciativa me encanta gracias!!!!!