56. Programación en Java || Matrices || Ejercicio - Determinar si una matriz es simétrica o no

  Рет қаралды 92,269

ProgramacionATS

ProgramacionATS

7 жыл бұрын

Puedes apuntarte al curso completo en la siguiente plataforma:
Hotmart: go.hotmart.com/W79402623G?dp=1
En este vídeo vamos a resolver el siguiente ejercicio:
Ejercicio 1: Crear y cargar una matriz de tamaño n x m y decir si es simétrica o no.
Visita mi sitio web para más cursos:
programacionats.zenler.com
Sigueme por las redes sociales:
Facebook ProgramacionATS: goo.gl/sqmEE1
Twiter: goo.gl/WE4oaP
Hotmail: alejandro.acb@hotmail.com
Facebook personal: goo.gl/xL9qLl
instagram: @alejandroats
Cuenta paypal para donaciones: migueltaboadas@hotmail.com

Пікірлер: 153
@orlypita6127
@orlypita6127 3 ай бұрын
Mi aporte del 2do ejercicio, aunque sé que ya no estas aqui para verlo, dejaste un gran legado, y muchos como yo, seguiran aprendiendo de tus videos siempre. //Crear y cargar 2 matrices de tamaño 3x3, sumarlas y mostrar su suma import java.util.Scanner; public class Ejercicio2_Matriz { public static void main(String[] args){ Scanner in= new Scanner(System.in); int matriz1[][]=new int[3][3],matriz2[][]= new int[3][3]; int Suma[][]= new int[3][3]; System.out.println("Llene la matriz 1"); for (int i = 0; i
@FernandoSanchezDaza
@FernandoSanchezDaza 5 жыл бұрын
/*Ejercicio 2: Crear y cargar dos matrices de tamaño 3x3, sumarlas y mostrar su resultado.*/ package ejercicio_2; import java.util.Scanner; /* *@author Fernando Sanchez */ public class Ejercicio_2 { public static void main(String[] args) { Scanner entrada = new Scanner(System.in); int matriz1[][] = new int[3][3]; int matriz2[][] = new int[3][3]; System.out.print("Suma de dos matrices cuadradas 3x3."); System.out.println(" Matriz 1: "); for(int i=0;i
@Lola-st9fw
@Lola-st9fw 5 жыл бұрын
Gracias de nuevo ¡¡¡ clarito , conciso y comprensible ¡¡
@luisvaldosabundez5294
@luisvaldosabundez5294 5 жыл бұрын
Gracias amigo, me ayudaste bastante en comprender y así poder realizar mi tarea, saludos!!!! :), me suscribo
@samuelgonzalez5358
@samuelgonzalez5358 4 жыл бұрын
Gracias a Dios por tu vida amigo, espero estes orgulloso de tus alumnos
@sebas_aristi
@sebas_aristi Жыл бұрын
Te amo hermano, gracias por la huella que dejaste
@hayamotopadre2491
@hayamotopadre2491 6 жыл бұрын
Eres el mejor explicando Bro, Siempre que tengo problemas con algun programa, tu haces que pueda ver mis errores, Gracias!!! por seguir aportando con este tipo de material
6 жыл бұрын
Muchas gracias :) Un saludo desde Perú
@joelizaguirre5282
@joelizaguirre5282 5 жыл бұрын
Gracias man sos un crack
@ProgramacionJATO
@ProgramacionJATO Жыл бұрын
Excelente, muchas gracias!! Estoy aprendiendo y tus explicaciones hacen todo más sencillo de comprender. 😉 Este es mi ejercicio: import java.util.Scanner; public class Matriz { public static void main(String[] args) { int matriz1[][]=new int [3][3]; int matriz2[][]=new int [3][3]; int suma1=0, suma2=0, sumatotal=0; Scanner sc_obj = new Scanner (System.in); System.out.println("Digite la matriz Nro.1: "); for(int i=0; i
@alexlopz5342
@alexlopz5342 5 жыл бұрын
Porque mientras j
@francomaty
@francomaty 7 жыл бұрын
CAPO!! EL MEJOR LEJOS
@nelsonbetancourt2175
@nelsonbetancourt2175 6 жыл бұрын
Muchas gracias.
@jeffreyindri
@jeffreyindri 6 жыл бұрын
Excelente como siempre, gracias
@AngelGonzalez-yo5gy
@AngelGonzalez-yo5gy 7 жыл бұрын
el mejor :)
@dannyperez3063
@dannyperez3063 Жыл бұрын
exelente video
@yadhfer
@yadhfer 6 жыл бұрын
Muy buen video, este es mi código del ejercicio import java.util.Scanner; import javax.swing.JOptionPane; public class Ejercicio2_Matrices { public static void main(String[] args){ Scanner entrada = new Scanner(System.in); final int nFilas1 = 3, nColumnas1 = 3; final int nFilas2 = 3, nColumnas2 = 3; final int nFilas3 = 3, nColumnas3 = 3; int matriz1[][] = new int[nFilas1][nColumnas1]; int matriz2[][] = new int[nFilas2][nColumnas2]; int matriz3[][] = new int[nFilas3][nColumnas3]; //Llenando la primera matriz de 3x3. System.out.println("Ingresa elementos de la primera matriz"); for(int i = 0; i < nFilas1; i++){ for(int j = 0; j < nColumnas1; j++){ System.out.print("Matriz [" + i + "][" + j + "]: "); matriz1[i][j]= entrada.nextInt(); } System.out.println(" "); } //Llenando la segunda matriz de 3x3. System.out.println("Ingresa elementos de la segunda matriz"); for(int i = 0; i < nFilas2; i++){ for(int j = 0; j < nColumnas2; j++){ System.out.print("Matriz [" + i + "][" + j + "]: "); matriz2[i][j]= entrada.nextInt(); } System.out.println(" "); } //Llenando en una tercera matriz de 3x3, la suma de las dos matrices. System.out.println("Muestra la suma de ambas Matrices"); for(int i = 0; i < nFilas3; i++){ for(int j = 0; j < nColumnas3; j++){ matriz3[i][j] = matriz1[i][j] + matriz2[i][j]; System.out.println("Matriz3[" + i + "][" + j + "]: " + matriz3[i][j]); } System.out.println(" "); } } }
@ChristianRodriguez-tm3jg
@ChristianRodriguez-tm3jg Жыл бұрын
simply the best
@juanpaVlz
@juanpaVlz 2 жыл бұрын
CRACK!
@wz_alex9798
@wz_alex9798 6 жыл бұрын
listo el 2 para quien no haya podido hacerlo o entendido que hacer aqui esta mi codigo public static void main(String[] args) { Scanner entrada = new Scanner(System.in); int matriz1[][]; int matriz2[][]; int n1 , n2 ,numero; n1=Integer.parseInt(JOptionPane.showInputDialog("Introduzca el numero de filas del primera y segunda matriz")); n2=Integer.parseInt(JOptionPane.showInputDialog("Introduzca el numero de columnas del primera y segunda matriz")); matriz1 = new int [n1][n2]; matriz2 = new int [n1][n2]; System.out.println("Introduzca numeros de la primera matriz"); for(int i=0;i
@karloz445
@karloz445 6 жыл бұрын
Excelente vídeo gracias Aprovecho para una pregunta, este método solo sirve para ordenar enteros o también String? gracias nuevamente Saludos desde Bogotá Colombia.
@josealfredogarciaaguilar9462
@josealfredogarciaaguilar9462 5 жыл бұрын
En realidad lo complicado del programa es la lógica de los While hacia dentro
@samuelnarciso9110
@samuelnarciso9110 5 жыл бұрын
Muy bueno tu video, pero me parece que tienes un error en el segundo while, en su paréntesis (j
@eduardovarela4866
@eduardovarela4866 5 жыл бұрын
yo tambien estoy enredado en eso, no se se me podria explicar como seria porfa
@malla9171
@malla9171 3 жыл бұрын
Está bien como lo puso en el video(aunque creo que es un poco tarde para responder xd), la cosa es que si i y j llegan a ser iguales estarías comparando elementos iguales lo cual sería redundante matriz[0][0]==matriz[0][0].
@yourfavouriteman
@yourfavouriteman 4 жыл бұрын
Mi querido Alejandro, yo haría el programa del ejercicio num 1 de forma distinta. ¿Verdad que estás evaluando si la matriz introducida es simétrica? Al ejeutar el programa, éste te pide el n de filas y el n de columnas. En caso de que sean distintas, la matriz no será cuadrada y por tanto no será simétrica. Aquí os dejo el programa que sería el que evitaría dicho procedimiento. import java.util.*; import javax.swing.*; public class MatrizSimetrica { public static void main(String[] args) { Scanner entrada = new Scanner(System.in); int matriz[][],nFilas,nColumnas; boolean simetrica = true; nFilas = Integer.parseInt(JOptionPane.showInputDialog("Introduce el número de filas: ")); nColumnas = Integer.parseInt(JOptionPane.showInputDialog("Introduce el número de columnas: ")); matriz = new int[nFilas][nColumnas]; if(nFilas != nColumnas) { JOptionPane.showMessageDialog(null, "Matriz no cuadrada"); System.exit(0); } else { System.out.println("Inserta datos de la matriz:"); for(int i=0; i
@inventorg.e1
@inventorg.e1 4 жыл бұрын
pero ya no te va poder responder no c si sabes pero el ya fallecio de cancer de rodilla segun recuerdo
@jorgecld8278
@jorgecld8278 2 жыл бұрын
re triste que se nos fue y cada q veo preguntas asi me lo recuerda
@TheNitro1544
@TheNitro1544 Жыл бұрын
Lo hice a mi manera antes de ver el video, esta enredado pero funciona xd: import javax.swing.*; public class Main{ public static void main(String[] args){ int filas; int columnas; boolean parar = false; filas = Integer.parseInt(JOptionPane.showInputDialog("Inserte el numero de filas que desee")); columnas = Integer.parseInt(JOptionPane.showInputDialog("Inserte el numero de columnas que desee")); int matriz[][] = new int[filas][columnas]; for(int i = 0 ; i < filas ; i++){ for(int j = 0 ; j < columnas ; j++){ matriz[i][j] = Integer.parseInt(JOptionPane.showInputDialog("Inserte el numero que quiera en la matriz")); } } if(filas == columnas){ for(int i = 0 ; i < filas ; i++){ for(int j = 0 ; j < columnas ; j++){ if(matriz[i][j] != matriz[j][i]){ JOptionPane.showMessageDialog(null,"Su matriz no es simetrica!"); parar = true; break; }else { JOptionPane.showMessageDialog(null, "Su matriz es simetrica!"); break; } } if(parar == true) { break; }else { break; } } }else{ JOptionPane.showMessageDialog(null,"Su matriz no es simetrica!"); } } }
@brianrios6714
@brianrios6714 3 жыл бұрын
Sos muy toro! gracias
@CeFer91
@CeFer91 2 жыл бұрын
/*Ejercicio 1 antes de ver video y explicado todo en JOptionPane */ package JavaApplication; import javax.swing.JOptionPane; public class JavaApplication { public static void main(String[] args) { int nF, nC; boolean simetrica=false; String matrizString = ""; nF = Integer.parseInt(JOptionPane.showInputDialog("Ingrese la cantidad de filas")); nC = Integer.parseInt(JOptionPane.showInputDialog("Ingrese la cantidad de columnas")); int matriz[][] = new int[nF][nC]; //Ingreso de valores de la matriz for (int i = 0; i < nF; i++) { for (int j = 0; j < nC; j++) { matriz[i][j] = Integer.parseInt(JOptionPane.showInputDialog("Fila " + i + " Columna " + j + ": Ingrese un número")); matrizString+=matriz[i][j]+" "; // Para imprimir una fila entera en JOptionPane la transformamos a String } matrizString+=" "; //Cada vez q termina de ingresarse una fila, se le aumenta un salto de línea para siguiente fila } //Comprobación de simetría if (nF == nC) { //1.- Tienen que tener mismo numero de filas y de columnas for (int i = 0,j=0; i < nF; i++,j++) { if (matriz[i][j] == matriz[j][i]) { //2.- Deben ser iguales los valores al invertirse simetrica=true; }else{ simetrica=false; break; //Si tan solo un valor no cumple entonces se rompe el ciclo e imprime que la matriz no es simetrica } } if (simetrica==true){ JOptionPane.showMessageDialog(null, matrizString); JOptionPane.showMessageDialog(null,"La matriz es simétrica."); } } else { JOptionPane.showMessageDialog(null, matrizString); JOptionPane.showMessageDialog(null, "La matriz no es simétrica"); } } }
@baiges9596
@baiges9596 4 жыл бұрын
Descansa en paz🙏🏻
@idsartjr3946
@idsartjr3946 7 жыл бұрын
Cuantos videos harás de este bloque?
@yoniberplay8655
@yoniberplay8655 6 жыл бұрын
EJERCICIO 2. /* CREAR Y CARGAR DOS MATRICEZ DE TAMA;NO 3X3 SUMARLAS Y MOSTRAR SU SUMA*/ package primervideo; import java.util.Scanner; import javax.swing.JOptionPane; public class Primervideo { public static void main(String[] args) { Scanner teclado = new Scanner(System.in); int matriz1[][],matriz2[][],nfilas1,ncolumnas1,nfilas2,ncolumnas2; int matriz3[][]; nfilas1=Integer.parseInt(JOptionPane.showInputDialog("1.DIGITE EL NUMERO DE FILAS")); ncolumnas1=Integer.parseInt(JOptionPane.showInputDialog("1.DIGITE EL NUMERO DE COLUMNAS")); matriz1= new int [nfilas1][ncolumnas1]; System.out.println("INGRESE LOS DATOS DE LA PRIMERA MATRIZ. "); for (int i=0;i
@TheRICMANZAM
@TheRICMANZAM 5 жыл бұрын
porque en el while se indica que el numero de columnas tiene que ser menor al numero de filas (j < i)???
@DARKO_GS
@DARKO_GS 3 жыл бұрын
lo resolviste?? no entiendo eso
@jorgereyes795
@jorgereyes795 2 жыл бұрын
@@DARKO_GS es facil bro te lo pongo de esta manera matriz 1 2 3 2 4 5 3 5 6 El numero 1 no tiene caso que lo evalues ya que al estar en una posicion donde se cruzan ambas matrices va a valer lo mismo si o si entonces esto permite que el programa no de mas vueltas de las necesarias Supongamos que ahora i vale 1, significa que va a llegar un punto en el que matriz en ij y ji se cruzen en este caso seria el numero 4, al igual no tiene caso evaluzarlo, y pasaria lo mismo para el 6. recuerda que cuando la matriz tiene [i][j] lo que se va a mover es la columna y si vale [j][i] lo que se va a mover es la fila. Espero me entiendas bro.
@TrappingFire
@TrappingFire Жыл бұрын
//Crear y cargar dos matrices de tamaño 3x3, sumarlas y mostrar su suma Scanner entrada = new Scanner(System.in); int matriz1[][],matriz2[][],suma1y2[][]; matriz1=new int[3][3]; matriz2=new int[3][3]; suma1y2=new int[3][3]; //Llenamos la matriz 1 System.out.println("Matriz 1"); for(int i=0; i
@mahmudahmadineyad4998
@mahmudahmadineyad4998 7 жыл бұрын
Cuando vamos a el POO?
@JLopez7991
@JLopez7991 5 жыл бұрын
Por qué pones en el 2do While (j < i) ?
@juanalegria7127
@juanalegria7127 4 жыл бұрын
yo me pregunto lo mismo :´v
@ImSnow17
@ImSnow17 4 жыл бұрын
ahí se equivoco yo creo pero debería ser j
@ImSnow17
@ImSnow17 4 жыл бұрын
@@juanalegria7127 ahí se equivoco yo creo pero debería ser j
@OatmealPancake
@OatmealPancake 4 жыл бұрын
Hallé el mismo problema en Google, y hacen lo mismo de "j
@frangilgon
@frangilgon 3 жыл бұрын
en la matriz, hay que tener en cuenta que la diagonal que se forma (0,0; 1,1;2,2;3,3...) siempre va a resultar igual, ya que da igual que tengas matriz[i][j] o matria [j][i] (las coordenadas son las mismas) por tanto, no es necesario comprobarlas. Por otro lado, queremos comprobar el triángulo que se forma bajo la diagonal con el que se forma sobre la diagonal. Si utilizaramos j
@manuelveraangulo7491
@manuelveraangulo7491 Жыл бұрын
aquí esta ele ejercicio que realizo programación ATS: package matriz3; // @author PROGRAMACIÓN ATS import java.util.Scanner; //Saber si la Matriz Simetrica public class Matriz3 { public static void main(String[] args) { Scanner entrada = new Scanner (System.in); int matriz [][],filas,columnas; boolean simetrica=true; System.out.print("Introduce el numero de filas:"); filas = entrada.nextInt(); System.out.print("Introduce el numero de columnas:"); columnas = entrada.nextInt(); matriz = new int [filas][columnas]; System.out.println(" Llenando la matriz"); for (int i = 0; i < filas; i++) { for (int j = 0; j < columnas; j++) { System.out.print("matriz ["+i+"]["+j+"]: "); matriz[i][j] = entrada.nextInt(); } } if (filas==columnas) { int i,j; i=0; while (i
@oscardiaz7962
@oscardiaz7962 3 жыл бұрын
que en paz descanses amigo.... quería solo comentar que he probado estos códigos en netbeans 12.3 y dan muchos errores de compilación por ejemplo si quitas los ln finales del System.out.print el programa se bloca y no continua mas, también probe la solución diferente escrita en los comentarios y también genera errores de ciclos infinitos.. y estoy seguro que controle bien la sintaxis.. alguien tiene idea si es un problema de las nuevas versiones de netbeans?
@georgetyrakowski4775
@georgetyrakowski4775 4 жыл бұрын
Metodo del Ejercicio 2. public static int[][] sumarMatrices(int[][] matriz1, int[][] matriz2){ int [][] matrizSuma= new int[matriz1.length][matriz1.length]; for(int i = 0; i < matriz1.length; i++){ for(int j = 0; j < matriz2.length; j++){ matrizSuma[i][j] = matriz1[i][j]+matriz2[i][j]; } } return matrizSuma; }
@frank1d1
@frank1d1 3 ай бұрын
Creo que está un poco ambiguo el ejercicio. No sé si es sumar la matriz para que quede 6x6 o sumar los números que están dentro de la matriz. Quedaría una tercera matriz con la suma de ambos 🤔. De resto, excelente video, todo muy bien explicado
@samuelespinoza885
@samuelespinoza885 3 жыл бұрын
Scanner entrada = new Scanner(System.in); int matriz[][], nFilas, nColumnas; int suma = 0; nFilas = Integer.parseInt(JOptionPane.showInputDialog("digite el numero de filas: ")); nColumnas = Integer.parseInt(JOptionPane.showInputDialog("digite el numero de columnas: ")); matriz = new int [nFilas][nColumnas]; //digitando la matiz System.out.println("Digite la matriz"); for (int i = 0; i < nFilas; i++) {//filas for (int j = 0; j < nColumnas; j++) {//columnas System.out.print("matriz ["+i+"]["+j+"]: "); matriz[i][j] = entrada.nextInt(); //sumando la matriz suma = suma + matriz[i][j]; } } //imprimiendo la matriz System.out.println(" La matriz es"); for (int i = 0; i < nFilas; i++) { for (int j = 0; j < nColumnas; j++) { System.out.print(matriz[i][j]); } System.out.println(""); } System.out.println("suma es igual a: "+suma);
@Dannrar
@Dannrar 2 жыл бұрын
Respecto de la comprobación de si la matriz puede ser simétrica comprobando el hecho de que, como primera medida, sea cuadrada, me parece que el código debería de entrada emitir un mensaje que lo anunciara, razón por la cual metí dentro del primer 'if' el llenado de la matriz, luego de que se haya confirmado que, efectivamente, la matriz es cuadrada. Pero es más sencillo en el código que queda así: Scanner entrada = new Scanner(System.in); int matriz[][], nFilas, nColumnas; boolean simetria = true; nFilas = Integer.parseInt(JOptionPane.showInputDialog("Digite el nº de filas de la matriz: ")); nColumnas = Integer.parseInt(JOptionPane.showInputDialog("Digite el nº de columnas de la matriz: ")); matriz = new int[nFilas][nColumnas]; // verificando si la matriz es simétrica o no. if (nFilas == nColumnas) { // Verificando si la matriz es cuatrada // Llenando la matriz. for (int i = 0; i < nFilas; i++) { for (int j = 0; j < nColumnas; j++) { System.out.print("Digite la posición [" + i + "][" + j + ": "); matriz[i][j] = entrada.nextInt(); } } // Verificando la matriz transpuesta. int i = 0, j = 0; // 'i' es el iterador para el nº de filas; 'j' es el iterador para el nº de columnas. while (i < nFilas && simetria == true) { // While para filas. while (j < i && simetria == true) { // While para columnas. if(matriz[i][j] != matriz[j][i]){ simetria = false; } j++; } i++; } if(simetria==true){ JOptionPane.showMessageDialog(null,"La matriz es simétrica."); } else { JOptionPane.showMessageDialog(null, "La matriz no es cuadrada pero no es simétrica."); } } else { JOptionPane.showMessageDialog(null, "La matriz no es cuadrada, por tanto, no puede ser simétrica."); } ¡Saludos!
@cristianstivenlopezarcinie8706
@cristianstivenlopezarcinie8706 2 жыл бұрын
buenas noches pueden suber un video que me vida grafos y matrices y tuplasen java a) Se debe ingresar una matriz por teclado de n x n elementos. b) La matriz relacional (MR) debe ser cuadrada para poder indicar las propiedades, debe validar esa opción. c) En su defecto que la matriz puede se genere directamente por el sistema, con un modelo aleatorio o que el usuario lo indique directamente por pantalla. d) Una vez ingresada la matriz, el aplicativo tiene que poder captar las relaciones R que genere la matriz y mostrarlas. e) Realizado el paso anterior, ustedes podrán obtener de manera automática las relaciones o preguntándole al sistema que pruebe una por una o todas las relaciones al mismo tiempo, como mejor le parezca. f) Como salida el aplicativo tendrá que mostrar si la matriz ingresada comprende o no, alguna de las propiedades anteriores y si posee alguna(s) relación de orden. g) Por último, que genere el grafo dirigido basado en la matriz original MR y lo presente en pantalla. h) Se deben validar las entradas y las salidas de la matriz en el sistema, al igual que cualquier elemento de entrada y salida de las funciones. con estos pasos estoy envalado con esta tarea
@leandrogaston7943
@leandrogaston7943 Жыл бұрын
Ejercicio 2: int[][] matriz; int nFilas, nColumnas, suma = 0; nFilas = Integer.parseInt(JOptionPane.showInputDialog("Digite el numero de filas: ")); nColumnas = Integer.parseInt(JOptionPane.showInputDialog("Digite el numero de columnas: ")); matriz = new int[nFilas][nColumnas]; System.out.println("Digite la cantidad de numeros: "); for (int i = 0; i < nFilas; i++) { for (int j = 0; j < nColumnas; j++) { System.out.print("Matriz["+(i+1)+"]["+(j+1)+"]: "); matriz[i][j] = entrada.nextInt(); } } int j = 0; for (int i = 0; i < nFilas; i++) { suma += matriz[i][j]; suma += matriz[i][j+1]; suma += matriz[i][j+2]; } System.out.println("La suma de la matriz es: "+suma); }
@woquendoG
@woquendoG 6 жыл бұрын
Ejercicio 2 Scanner entrada = new Scanner(System.in); int matriz1[][]; int matriz2[][]; int nFilas, nCols, nFilas2, nCols2, suma = 0; // matriz 1 System.out.println("Digite el número de filas de la matriz uno"); nFilas = entrada.nextInt(); System.out.println("Digite el número de columnas de la matriz uno"); nCols = entrada.nextInt(); matriz1 = new int[nFilas][nCols]; System.out.println("Llenando la matriz uno"); for (int i = 0; i < nFilas; i++) { for (int j = 0; j < nCols; j++) { System.out.println("Matriz1[" + i + "][" + j + "] "); matriz1[i][j] = entrada.nextInt(); } } // matriz 2 System.out.println("Digite el número de filas de la matriz dos"); nFilas2 = entrada.nextInt(); System.out.println("Digite el número de columnas de la matriz dos"); nCols2 = entrada.nextInt(); matriz2 = new int[nFilas2][nCols2]; System.out.println("Llenando la matriz dos"); for (int i = 0; i < nFilas2; i++) { for (int j = 0; j < nCols2; j++) { System.out.println("Matriz2[" + i + "][" + j + "] "); matriz2[i][j] = entrada.nextInt(); } } // Sumando ambas matrices for (int i = 0; i < nFilas; i++) { for (int j = 0; j < nCols; j++) { suma = suma + matriz1[i][j] + matriz2[i][j]; } } System.out.println("la suma de las matrices es " + suma); }
@sandrovilunir8240
@sandrovilunir8240 7 жыл бұрын
necesito ayuda para un programa en c++ , podrías ??
@Mr_Chango
@Mr_Chango 5 жыл бұрын
* Crear y cargar dos matrices de tamaño 3*3, sumarlas y mostrar su suma */ package ejercicio2_matrices; import java.util.Scanner; public class Ejercicio2_Matrices { public static void main(String[] args) { Scanner entrada = new Scanner(System.in); int matriz[][] = new int[3][3]; int matriz2[][] = new int[3][3]; int suma; System.out.println("Dijite la primera matriz: "); for(int i=0;i
@thejames616
@thejames616 3 жыл бұрын
Aquí está mi ejercicio 2 resuelto: package ejercicios_14; import java.util.Scanner; import javax.swing.JOptionPane; public class ejercicios_14 { public static void main(String[] args) { Scanner entrada=new Scanner(System.in); int[][] matriz1,matriz2,matrizS; matriz1=new int[3][3]; matriz2=new int[3][3]; matrizS=new int[3][3]; System.out.println("Llenar la primera matriz: "); for(int i=0;i
@isaacperales9580
@isaacperales9580 7 жыл бұрын
Si colocas // If(nfilas == ncol){ 》mas arriba se cancelara toda funcion en caso de ser asimetrica.
@vladimirputin105
@vladimirputin105 4 ай бұрын
ejercicio: package ejercises; public class Ejercicio20 { public static void main(String[] args) { int[][] matriz1 = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; int[][] matriz2 = {{9, 8, 7}, {6, 5, 4}, {3, 2, 1}}; int[][] suma = new int[3][3]; System.out.println("sumando matrices...."); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { suma[i][j] = matriz1[i][j] + matriz2[i][j]; } } System.out.println("mostrando matriz...."); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (j == 2){ System.out.println(suma[i][j]); }else{ System.out.print(suma[i][j] + " "); } } } } }
@xnor.stifler
@xnor.stifler 3 жыл бұрын
UNA pregunta ; el Integer.parseInt ::::::::no recoje datos de matris o esque estoy mal , solo me funciona con el Scanner Scanner escanear = new Scanner(System.in); int filas= Integer.parseInt(JOptionPane.showInputDialog(" DIJITE EL NUMERO DE FILAS ")); int columnas= Integer.parseInt(JOptionPane.showInputDialog(" DIJITE EL NUMERO DE COLUMNAS ")); int matiz[][] =new int [filas][columnas]; for (int i = 0; i < filas; i++) { for (int j = 0; j < columnas; j++) { System.out.println(" dijite los elementos ["+(i+1)+"]"+"["+(j+1)+"]"); matiz[i][j] = escanear.nextInt(); // matiz[i][j]=Integer.parseInt(" dijite los elementos ["+(i+1)+"]"+"["+(j+1)+"]"); // no funciona con esto } } for (int i = 0; i < filas; i++) { for (int j = 0; j < columnas; j++) { System.out.println(" la matris es : ["+i+"] ["+j+"]"); } }
@jorgereyes795
@jorgereyes795 2 жыл бұрын
Es simple bro matriz[i][j]=Integer.parseInt(JOptionPane.showInputDialog(null,"Ingrese ["+i+"]["+j+"]: "));
@SUPERNOVA-vn8dh
@SUPERNOVA-vn8dh Жыл бұрын
/* Ejercicio 2: Crear y cargar dos matrices de tamaño 3x3 , sumarlas y mostrar su suma . */ import java.util.Scanner; public class ej2 { public static void main(String[] args) { Scanner entrada = new Scanner(System.in); int matriz1[][] = new int[3][3]; int matriz2[][] = new int[3][3]; //almacenamos los valores System.out.println("Digite matriz 1 de 3X3:"); for(int i=0;i
@hugofloresmorales2387
@hugofloresmorales2387 9 ай бұрын
aportación :) Scanner entrada = new Scanner (System.in); int matrizA [][], matrizB[][],resultado[][]; int nFilas=3, nCol=3; matrizA = new int [nFilas][nCol]; matrizB = new int [nFilas][nCol]; resultado = new int [nFilas][nCol]; //llenando la matriz A System.out.print("Llenando la matriz A"); for(int i=0; i
@woquendoG
@woquendoG 6 жыл бұрын
Alguien me explica por que j< i? no entendi esa parte y el no la explica
@danielrangel6593
@danielrangel6593 5 жыл бұрын
Por Que estas evaluando que no sea simetrica , por lo tanto si i < j o j< i entonces la matriz no es simetrica.
@wachemowe
@wachemowe 3 жыл бұрын
Se que es atrasada la respuesta, pero eso es para evitar comparar cuando i y j valen lo mismo, porque la comparación seria matriz[0][0] != matriz[0][0] o matriz[1][1] != matriz[1][1], y en esos casos seria la misma posición en la matriz, por lo que sería una vuelta extra que no sirve para nada. Con j
@santiagogarcia220
@santiagogarcia220 3 жыл бұрын
@@wachemowe no pues. empiezo con J e i igualados a 0. Por lo tanto, con 0 y 0 no se cumple que j
@malla9171
@malla9171 3 жыл бұрын
Yo también estaba pensando lo mismo, pero luego de analizar me di cuenta que omite comparar los elementos de la diagonal principal, ya que estos al transponerla siempre quedarán iguales, intenta probar con cualquier matriz cuadrada
@DARKO_GS
@DARKO_GS 3 жыл бұрын
@@malla9171 ohm ya , igual pensaba que omitía algunas posiciones, es que me confundía lo que dicia Alejandro "va comprobando por cada posicion" o algo asi , pero creia que era por cada posición
@danielcastiblanco5067
@danielcastiblanco5067 5 жыл бұрын
Ejercicio 2 de matrices package matrizejercicio2; import java.util.Scanner; /** * * @author Daniel */ public class Matrizejercicio2 { /** * @param args the command line arguments */ public static void main(String[] args) { int matriz1 [][],matriz2[][], m1_filas, m2_filas, m1_columnas, m2_columnas; Scanner entrada = new Scanner (System.in); System.out.println("Digite el número de filas de la matriz 1: "); m1_filas = entrada.nextInt(); System.out.println("Digite el número de columnas de la matriz 1: "); m1_columnas = entrada.nextInt(); System.out.println("Digite el número de filas de la matriz 2: "); m2_filas = entrada.nextInt(); System.out.println("Digite el número de columnas de la matriz 2: "); m2_columnas = entrada.nextInt(); matriz1 = new int[m1_filas][m1_columnas]; matriz2 = new int[m2_filas][m2_columnas]; //guardamos matriz 1 System.out.println("Digite la matriz 1: "); for(int i=0;i
@pancraciodelosanglesbenedi4092
@pancraciodelosanglesbenedi4092 4 жыл бұрын
tengo un problema al mostrar mi matriz, me sale de corrido en una sola fila, no en cuadro, allguien por favor que me ayude
@coffeebeans3012
@coffeebeans3012 7 ай бұрын
Ejercicio 2 (JavaScript) : let matriz1 = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ]; let matriz2 = [ [9, 8, 7], [6, 5, 4], [3, 2, 1] ]; let resultado = []; for (let i = 0; i < matriz1.length; i++) { resultado[i] = []; for (let j = 0; j < matriz1[i].length; j++) { resultado[i][j] = matriz1[i][j] + matriz2[i][j]; } } console.log("La suma de las matrices es:"); console.log(resultado);
@hernandezloredoisaac6667
@hernandezloredoisaac6667 Жыл бұрын
Ejercicio 2: package ejercicio2_matrices; import java.util.Scanner; public class Ejercicio2_Matrices { public static void main(String[] args) { Scanner entrada = new Scanner(System.in); int matriz1[][]=new int[3][3]; int matriz2[][]=new int[3][3]; int SumaMatrices[][]=new int[3][3]; //Pedimos los elementos de la matriz 1 System.out.println("Digite la matriz 1: "); for(int i=0;i
@johnescobar9951
@johnescobar9951 3 жыл бұрын
No entiendo la parte del 2 while donde dice j
@josuep326
@josuep326 3 жыл бұрын
Creo que esa duda quedará pendiene bro, el tipo ya está en el cielo
@johnescobar9951
@johnescobar9951 3 жыл бұрын
@@josuep326 lo se, pero lo pregunto x si alguien mas entendia esa logica, abajo en otro comentario hacen una prueba de escritorio y tampoco da
@jorgereyes795
@jorgereyes795 2 жыл бұрын
@@johnescobar9951 es facil bro te lo pongo de esta manera matriz 1 2 3 2 4 5 3 5 6 El numero 1 no tiene caso que lo evalues ya que al estar en una posicion donde se cruzan ambas matrices va a valer lo mismo si o si entonces esto permite que el programa no de mas vueltas de las necesarias Supongamos que ahora i vale 1, significa que va a llegar un punto en el que matriz en ij y ji se cruzen en este caso seria el numero 4, al igual no tiene caso evaluzarlo, y pasaria lo mismo para el 6. recuerda que cuando la matriz tiene [i][j] lo que se va a mover es la columna y si vale [j][i] lo que se va a mover es la fila. Espero me entiendas bro.
@TheNitro1544
@TheNitro1544 Жыл бұрын
Ejercicio 2: import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner in = new Scanner(System.in); int matriz1[][] = new int[3][3]; int matriz2[][] = new int[3][3]; int matriz3[][] = new int[3][3]; System.out.println("Rellene la primera matriz"); for(int i = 0 ; i < 3 ; i++){ for(int j = 0 ; j < 3 ; j++){ System.out.println("Inserte un numero"); matriz1[i][j] = in.nextInt(); } } System.out.println("Rellene la segunda matriz"); for(int i = 0 ; i < 3 ; i++){ for(int j = 0 ; j < 3 ; j++){ System.out.println("Inserte un numero"); matriz2[i][j] = in.nextInt(); } } for(int i = 0 ; i < 3 ; i++){ for(int j = 0 ; j < 3 ; j++){ matriz3[i][j] = matriz1[i][j] + matriz2[i][j]; } } for(int i = 0 ; i < 3 ; i++){ for(int j= 0 ; j < 3; j++){ System.out.print("["+matriz3[i][j]+"]"); } System.out.println(""); } } }
@fernandogal1
@fernandogal1 Жыл бұрын
Alguien me podria explicar cual es la funcion del while en la linea 34, es que no entiendo si j es 0 y la i tambien es 0 como se haria esa comparacion porque quedaria como 0 es menor que 0
@jos1327
@jos1327 Жыл бұрын
la primera vez no se verifica porque ese número siempre debe ser igual, mira las tablas del inicio y te fijas que el 0 ya sea en fila o en columna siempre se encuentra en la misma posición [0][0], entonces ese no le evalúa y evalúa solo los bordes de la matriz
@Mikael_Hyacinth
@Mikael_Hyacinth 7 ай бұрын
Respecto al ejercicio 1 creo que se puede mejorar un poquito si se usan los ciclos for, asi me quedo a mi antes de ver el video --------------------------- import javax.swing.*; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int[][] matriz; int nFila, nCol; boolean simetrica = false; nFila = Integer.parseInt(JOptionPane.showInputDialog("Ingresa el numero de Filas.")); nCol = Integer.parseInt(JOptionPane.showInputDialog("Ingresa el numero de Columnas.")); matriz = new int[nFila][nCol]; if (nFila == nCol){ for (int i = 0; i < nFila; i++) { for (int j = 0; j < nCol; j++) { System.out.print("Matriz [" + i + "][" + j + "]: "); matriz[i][j] = in.nextInt(); } } for (int i = 0; i < nFila; i++) { for (int j = 0; j < nCol; j++) { simetrica = matriz[i][j] == matriz[j][i]; if (!simetrica){ break; } } if (!simetrica){ break; } } } if (!simetrica){ JOptionPane.showMessageDialog(null, "La matriz no es simetrica"); }else { JOptionPane.showMessageDialog(null, "La matriz es simetrica:"); } } }
@dealvin
@dealvin 5 жыл бұрын
por que ATS???
@aeamongol4299
@aeamongol4299 7 жыл бұрын
when estudias el tema antes que de llevar el curso
@juansebastianastudillozamb2724
@juansebastianastudillozamb2724 7 жыл бұрын
Ejercicio 1 sin ver el video :D //Ejercicio 1 //Juan Astudillo package repaso; import java.util.Arrays; import java.util.Scanner; import javax.swing.JOptionPane; public class Repaso { public static void main(String[] args) { //Variables int matriz [][], matrizT[][], columnas, filas; //Objeto escaner Scanner entrada= new Scanner(System.in); //Ingreso de las dimensiones de la mtrices filas = Integer.parseInt(JOptionPane.showInputDialog("Ingrese la cantidad de filas (n): ")); columnas = Integer.parseInt(JOptionPane.showInputDialog("Ingrese la cantidad de columnas (m): ")); //Crear matriz matriz = new int[filas][columnas]; matrizT = new int[columnas][filas]; //Llenar la matriz System.out.println("Digite la matriz: "); for(int i=0; i
@josealfredogarciaaguilar9462
@josealfredogarciaaguilar9462 5 жыл бұрын
Ordené el código de una manera distinta, para que, si las dimensiones de las filas y las columnas no son iguales, que no se pidan los números de la matriz. No tiene caso pedir los datos si igual no van a ser simétricas :v package Prácticas; //SE PIDEN LOS DATOS DE UNA MATRIZ Y MUESTRA SI ES O NO ES SIMÉTRICA public class MatrizSimetrica { public static void main(String[] args) { boolean sim = true; System.out.print("NÚMERO DE FILAS: "); int fil = Leer.datoInt(); System.out.print("NÚMERO DE COLUMNAS: "); int col = Leer.datoInt(); int[][] matriz = new int[fil][col]; if (fil == col) { // SI EL NÚMERO DE FILAS ES IGUAL AL NÚMERO DE COLUMNAS // SE PIDEN LOS DATOS SOLO SI TIENE EL MISMO NÚMERO DE FILAS Y DE COLUMNAS System.out.println("-CAPTURA DE DATOS-"); for (int a = 0; a < fil; a++) { for (int b = 0; b < fil; b++) { System.out.print("MATRIZ [" + a + "][" + b + "]: "); matriz[a][b] = Leer.datoInt(); } } // LÓGICA QUE COMPRUEBA SI SON SIMÉTRICAS O NO int i = 0, j; while (i < fil && sim == true) { j = 0; while (j < i && sim == true) { if (matriz[i][j] != matriz[j][i]) { sim = false; } j++; } i++; } if (sim == true) { System.out.println("LA MATRIZ SÍ ES SIMÉTRICA"); } else { System.out.println("LA MATRIZ NO ES SIMÉTRICA"); } } else { System.out.println("LA MATRIZ NO ES SIMÉTRICA"); } } }
@dirackta250
@dirackta250 2 жыл бұрын
/* Crear dos matrices de tamaño 3*3, sumarlas y mostrar su suma */ package Matrices; import java.util.Scanner; public class Ejer2 { public static void main(String[] args){ Scanner input = new Scanner(System.in); int matrizA[][] = new int[3][3]; int matrizB[][] = new int[3][3]; int suma[][] = new int[3][3]; //Relleno de las matrices System.out.println("Rellena tus matrices"); System.out.println(" Digita tu primer arreglo: "); for(int i = 0 ; i < 3 ; i++){ for(int j = 0 ; j < 3 ; j++){ System.out.println("Matriz ["+i+"]["+j+"]: "); matrizA[i][j] = input.nextInt(); } } System.out.println(" Digita tu segundo arreglo: "); for(int i = 0 ; i < 3 ; i++){ for(int j = 0 ; j < 3 ; j++){ System.out.println("Matriz ["+i+"]["+j+"]: "); matrizB[i][j] = input.nextInt(); } } //Sumando matrices System.out.println(" Esta es la suma de tus dos matrices "); for(int i = 0 ; i < 3 ; i++){ for(int j = 0 ; j < 3 ; j++){ suma[i][j] = matrizA[i][j]+matrizB[i][j]; //Imprimiendo Matriz suma System.out.println("Matriz suma["+i+"]["+j+"]: "+suma[i][j]+"."); } } } }
@Cosmoluo
@Cosmoluo 19 күн бұрын
//ejercicio2 Crear y cargar dos matrices de temano 3x3, sumarlas y mostar su resultado Scanner sc = new Scanner(System.in); int nFila, nCol, arreglo[][], arreglo2[][], suma[][]; //Crear y cargar dos matrices de temano 3x3 arreglo = new int[3][3]; suma = new int[3][3]; System.out.println("Digite la matriz: "); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("Matriz [" + i + "][" + j + "]: "); arreglo[i][j] = sc.nextInt(); } } //la matriz 2 arreglo2 = new int[3][3]; System.out.println(" La matriz 2 es: "); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("Matriz [" + i + "][" + j + "]: "); arreglo2[i][j] = sc.nextInt(); } } //sumarlas y mostar su resultado //obtener la matriz C como suma de las matrices A y B int i = 0, j = 0; for (i = 0; i < arreglo.length; i++) { for (j = 0; j < arreglo[i].length; j++) { suma[i][j] = arreglo[i][j] + arreglo2[i][j]; } } for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { System.out.print(suma[i][j] + " "); } System.out.println(""); } } }
@miguelparedes1822
@miguelparedes1822 Жыл бұрын
Ejercicio 1: /* Ejercicio 1: Crear y cargar una matriz de tamaño n x m y decir si es simétrica o no. */ package ejercicio_1; import java.util.Scanner; /** * * @author Miguel Paredes */ public class Ejercicio_1 { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here int nFilas,nColumnas; Boolean condicion1=false,condicion2=false; Scanner input = new Scanner (System.in); System.out.print(" Ingrese la cantidad de filas y columas de la matriz: "); nFilas = input.nextInt(); nColumnas = input.nextInt(); int matriz[][] = new int [nFilas][nColumnas]; int matrizt[][] = new int [nColumnas][nFilas]; for(int i=0;i
@Loko0055x
@Loko0055x Жыл бұрын
ejercicio 1 con mi propia logica xdd es similar pero no es igual espero les ayude mucho Scanner s = new Scanner (System.in); System.out.print("digite las filas demi matriz :"); int nfilas=s.nextInt(); System.out.print("digite las columnas de mi matriz : "); int ncolumnas =s.nextInt(); int [][]matriz= new int [nfilas][ncolumnas]; int cont=0; System.out.println("rrellenando mi matriz"); for (int i = 0; i < nfilas; i++) { for (int j = 0; j < ncolumnas; j++) { System.out.print("Matriz "+"["+i+"]" +"["+j+"]" + " :"); matriz[i][j]=s.nextInt(); } } System.out.println(""); for (int i = 0; i < nfilas; i++) { for (int j = 0; j < ncolumnas; j++) { System.out.print(""+matriz[i][j]+" "); } System.out.println(""); } System.out.println(""); if (nfilas==ncolumnas) { for (int i = 0; i < nfilas; i++) { for (int j = 0; j < ncolumnas; j++) { if (matriz[i][j]==matriz[j][i]) { cont++; } } for (int k = 0; k < nfilas; k++) { for (int j = 0; j < ncolumnas; j++) { System.out.print(""+matriz[j][k]+" "); } System.out.println(""); } } if (cont==9) { System.out.println("es simetrica"); } else{ System.out.println(" no es simetrica"); } } else{ System.out.println("no es simetrica ni cuadrada"); }
@danielbarretorojas1053
@danielbarretorojas1053 Жыл бұрын
for (int j = 0; j < ncolumnas; j++) inicialmente lo pense igual, pero luego analice por que se ponia i en vez de nColumnas y la razon es que cuando i y j valen lo mismo, es decir estan en la misma posicion el numero es el mismo, por lo que no tiene mucho sentido evaluarlos, y cuando utilizas nColumnas los evaluas todos- Digamos que al final, ambas formas te arrojan el resultado pedido, pero de ser un programa mucho mas grande, se vería mas la necesidad de no evaluar aquellas condiciones que no son necesarias.
@eltwinsanitymonopolio4460
@eltwinsanitymonopolio4460 Жыл бұрын
//en este codigo saque la transpuesta y verifique si es simetrica import java.util.Scanner; public class Main{ //primero se debe definir la matriz y despues su tamaño,no todo de una como en vectores. public static void main(String[] args) { int matriz[][],nFilas,num,transpuesta[][],nColumnas;//se define la matriz y la matriz transpuesta Scanner lea=new Scanner(System.in);//se crea el objeto del scanner Main m=new Main(); System.out.print("ingrese el tamaño de las filas:"); nFilas=lea.nextInt();//se leen las filas System.out.print("ingrese el tamaño de las columnas"); nColumnas=lea.nextInt();//se leen columnas matriz=new int[nFilas][nColumnas];//se define el tamaño de la matriz System.out.print("llene la matriz:"); for(int i=0;i
@CeFer91
@CeFer91 2 жыл бұрын
/*Ejercicio2 explicado*/ package JavaApplication; import javax.swing.JOptionPane; public class JavaApplication { public static void main(String[] args) { int m1[][] = new int[3][3]; int m2[][] = new int[3][3]; int suma[][] = new int[3][3]; String mat1="",mat2="",matSum=""; //Rellenando matriz 1 for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { m1[i][j] = Integer.parseInt(JOptionPane.showInputDialog("TABLA 1 Fila " + (i + 1) + " Columna " + (j + 1) + " Ingrese un numero")); mat1+= m1[i][j]+" "; //Creando String de Matriz 1 } mat1+=" "; //Salto de linea despues de rellenar una fila entera } //Rellenando matriz 2 for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { m2[i][j] = Integer.parseInt(JOptionPane.showInputDialog("TABLA 2 Fila " + (i + 1) + " Columna " + (j + 1) + " Ingrese un numero")); mat2+= m2[i][j]+" "; //Creando String de Matriz 2 } mat2+=" "; } //Sumando y agregando valores a Matriz Suma for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { suma[i][j] = m1[i][j] + m2[i][j]; matSum+= suma[i][j]+" "; //Creando String de MatrizSuma } matSum+=" "; } JOptionPane.showMessageDialog(null, "Matriz 1 "+mat1); JOptionPane.showMessageDialog(null, "Matriz 2 "+mat2); JOptionPane.showMessageDialog(null, "Suma "+matSum); } }
@Loko0055x
@Loko0055x Жыл бұрын
ejercicio 2 resuelto int [][]matriz1= new int [3][3]; int [][]matriz2= new int [3][3]; int suma=0; System.out.println("rellenado mi primera matriz"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("Matriz "+"["+i+"]" +"["+j+"]" + " :"); matriz1[i][j]=s.nextInt(); } } System.out.println("rellenado la segunda matriz"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("Matriz "+"["+i+"]" +"["+j+"]" + " :"); matriz2[i][j]=s.nextInt(); } } System.out.println(" mostrar resultados dela suma delas matrizes gaaaaaa"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { suma=matriz1[i][j]+matriz2[i][j]; System.out.println("["+suma+"]"); } System.out.println(""); }
@simonphoenix9096
@simonphoenix9096 11 ай бұрын
*_//EXERICISE_2_* Scanner input = new Scanner(System.in); int matriz1[][] = new int[3][3]; int matriz2[][] = new int[3][3]; System.out.println("carga la primera matriz"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("[" + i + "] [" + j + "]: "); matriz1[i][j] = input.nextInt(); } } System.out.println("carga la segunda matriz"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("[" + i + "] [" + j + "]: "); matriz2[i][j] = input.nextInt(); } } // suamndo las matrices System.out.println("la suma de la primera y segunda matriz es: "); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print((matriz1[i][j] + matriz2[i][j])+" "); } System.out.println(); }
@soyedwin-
@soyedwin- 5 жыл бұрын
Ejercicio 2 Scanner entrada = new Scanner(System.in); int matrix1[][], matrix2[][], fila, columna, suma [][], sumatotal=0; fila = Integer.parseInt(JOptionPane.showInputDialog("Favor introducir el numero de filas: ")); columna = Integer.parseInt(JOptionPane.showInputDialog("Favor introducir el numero de columna: ")); matrix1 = new int[fila][columna]; matrix2 = new int[fila][columna]; suma = new int[fila][columna]; if(fila !=columna){ JOptionPane.showMessageDialog(null, "Debe ingresar una matrix cuadrada"); } else{ System.out.println("Favor introducir los datos de la matrix la matrix 1: "); for (int i = 0; i < fila; i++) { for (int j = 0; j < columna; j++) { System.out.print("Matrix ["+i+ "]["+j+"]: "); matrix1[i][j] = entrada.nextInt(); } } System.out.println(" Favor introducir los datos de la matrix la matrix 2: "); for (int i = 0; i < fila; i++) { for (int j = 0; j < columna; j++) { System.out.print("Matrix ["+i+ "]["+j+"]: "); matrix2[i][j] = entrada.nextInt(); } } for (int i = 0; i < fila; i++) { for (int j = 0; j < columna; j++) { suma[i][j] = matrix1[i][j] + matrix2[i][j]; sumatotal += suma[i][j]; } } JOptionPane.showMessageDialog(null, " El resultado de la suma es: "+sumatotal); }
@yulmanmelindres3884
@yulmanmelindres3884 4 жыл бұрын
package pruebas; import java.util.Scanner; /* Ejercicio2: Crear y cargar dos matrices de tamaño 3x3, sumarlas y mostrar su suma. @Autor Yulman */ public class Pruebas { public static void main(String[] args) { Scanner entrada = new Scanner(System.in); int matriz[][] = new int[3][3]; int suma = 0; //PEDIR DATOS PARA LA MATRIZ for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("MATRIZ [" + i + "] [" + j + "]: "); matriz[i][j] = entrada.nextInt(); } } //SUMAR LAS MATRICES for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { suma += matriz[i][j]; } } //MOSTRAR SUMA TOTAL System.out.println(" La suma total de la matriz es: " + suma); } }
@homerosuper9180
@homerosuper9180 4 жыл бұрын
package ejercicio2; import java.util.Scanner; public class ejercicio2 { public static void main(String[] args) { // TODO Auto-generated method stub // crear dos matrices 3x3 y mostrar su suma Scanner entrada = new Scanner(System.in); //creamos las matrices int matriz1[][] = new int[3][3], matriz2[][] = new int[3][3]; //agregamos valores System.out.println("Agregamos valores a la primera matriz..."); for(int i=0; i
@miguel_mend_electronica5394
@miguel_mend_electronica5394 2 жыл бұрын
mi solucion del ejercicio 2: import java.util.Scanner; public class sumaMatriz { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner entrada = new Scanner(System.in); int nFil,nCol,matriz[][],nFilS,nColS,matrizS[][],matrizR[][] = null,tam; boolean suma=true; System.out.println(" Inserte el numero de filas del primer arreglo "); nFil=entrada.nextInt(); System.out.println(" Inserte el numero de columnas del primer arreglo "); nCol=entrada.nextInt(); matriz=new int [nFil][nCol]; System.out.println(" Inserte el numero de filas del segundo arreglo "); nFilS=entrada.nextInt(); System.out.println(" Inserte el numero de columnas del segundo arreglo "); nColS=entrada.nextInt(); matrizS=new int [nFil][nCol]; for(int i=0;i
@alfredopablo3462
@alfredopablo3462 3 жыл бұрын
Como solo era sumar, seria asi :) public static void main(String[] args) { Scanner entrada=new Scanner(System.in); int matrizA[][]=new int[3][3]; int matrizB[][]=new int[3][3]; int total=0,suma; for(int i=0;i
@botsquad9810
@botsquad9810 2 жыл бұрын
por si alguien necesita ayuda esta es una manera que vi un poco mas simple de hacer el programa
@botsquad9810
@botsquad9810 2 жыл бұрын
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner entrada=new Scanner(System.in); int matriz[][],nfilas,ncolumnas,bucle; System.out.println("Ingrese el numero de filas por favor: "); nfilas=entrada.nextInt(); System.out.println("Ingrese el numero de columnas por favor: "); ncolumnas=entrada.nextInt(); matriz= new int[nfilas][ncolumnas]; if(nfilas==ncolumnas){ System.out.println("ingrese los valores de la matriz"); for(int filas=0;filas
@edulatorrev
@edulatorrev 2 жыл бұрын
public static void main(String args[]) { int matriz[][] = {{3, 9, 3}, {9, 8, 9}, {3, 9, 3}}; int sumaFila = 0, sumaColumna = 0; boolean simetrica = true; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { sumaFila += matriz[i][j]; sumaColumna += matriz[j][i]; } if ((sumaFila != sumaColumna)) { simetrica = false; break; } } if (simetrica) { System.out.print("La matriz es simétrica"); } else { System.out.print("La matriz es asimétrica"); } }
@leonardolezcano7070
@leonardolezcano7070 6 жыл бұрын
public static void main(String[] args) { Scanner entrada = new Scanner(System.in); int sumaMatriz[][], matriz[][], matriz2[][], nFilas, nColumnas; nFilas = Integer.parseInt(JOptionPane.showInputDialog("Digite numero de filas de las matrices: ")); nColumnas = Integer.parseInt(JOptionPane.showInputDialog("Digite numero de columnas de las matrices: ")); matriz = new int[nFilas][nColumnas]; matriz2 = new int[nFilas][nColumnas]; sumaMatriz = new int[nFilas][nColumnas]; System.out.println("Llenar primer matriz: "); for(int i=0 ; i
@Dannrar
@Dannrar 2 жыл бұрын
Así me quedó el código del ejercicio nº2: Scanner entrada = new Scanner(System.in); int matriz1[][] = new int [3][3]; int matriz2[][] = new int [3][3]; int matrizSuma[][] = new int [3][3]; int suma=0; // Llenando las matrices System.out.println("Llenando la matriz nº 1."); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("Digite la posición [" + i + "][" + j + "]: "); matriz1[i][j] = entrada.nextInt(); } } System.out.println(""); System.out.println("Llenando la matriz nº 2."); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("Digite la posición [" + i + "][" + j + "]: "); matriz2[i][j] = entrada.nextInt(); } } System.out.println(""); // Imprimiendo las dos matrices for (int i = 0; i < 3; i++) { // Impresión matriz1 for (int j = 0; j < 3; j++) { System.out.print("["+matriz1[i][j]+"]"); } System.out.println(""); } System.out.println(""); for (int i = 0; i < 3; i++) { // Impresión matriz2 for (int j = 0; j < 3; j++) { System.out.print("["+matriz2[i][j]+"]"); } System.out.println(""); } System.out.println(""); // Sumando las matrices for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { suma = matriz1[i][j] + matriz2[i][j]; matrizSuma[i][j] = suma; } } // Imprimendo la suma de las matrices System.out.println("Suma de las matrices."); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("["+matrizSuma[i][j]+"]"); } System.out.println(""); } System.out.println(""); ======================================================= ¡Saludos!
@mamiki7429
@mamiki7429 4 жыл бұрын
public static void main(String[] args) { int fil, col, i, j, cont = 0; fil = Integer.parseInt(JOptionPane.showInputDialog("numero de filas")); col = Integer.parseInt(JOptionPane.showInputDialog("numero de columnas")); int matriz[][] = new int[fil][col]; while (fil == col) { for (i = 0; i < fil; i++) { for (j = 0; j < col; j++) { matriz[i][j] = Integer.parseInt(JOptionPane.showInputDialog("introduzca valor de la fila " + (i + 1) + " en la columna " + (j + 1))); } } for (i = 0; i < fil; i++) { for (j = 0; j < col; j++) { if (matriz[i][j] == matriz[j][i]) { cont++; } } } if (cont == fil * col) { JOptionPane.showMessageDialog(null, "la matriz es simetrica"); } else { JOptionPane.showMessageDialog(null, "la matriz no es simetrica"); } } if (fil != col) { JOptionPane.showMessageDialog(null, "la matriz no es simetrica"); } }
@justincarter360
@justincarter360 9 ай бұрын
Buenas, paso mi ejercicio 2: package CursoATS.Matriz; import java.util.Scanner; public class MatrizExc02 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int matriz01[][] = new int [3][3]; int matriz02[][] = new int [3][3]; int matrizResultado[][] = new int [3][3]; System.out.println("Ingrese los valores para la primera matriz:"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("matriz01["+i+"]["+j+"]: "); matriz01[i][j] = scanner.nextInt(); } } System.out.println("Ingrese los valores para la Segunda matriz:"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("matriz02["+i+"]["+j+"]: "); matriz02[i][j] = scanner.nextInt(); } } for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { matrizResultado[i][j] = matriz01 [i][j] + matriz02 [i][j]; } } System.out.println("la matriz Resultado es: "); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print(matrizResultado[i][j]); } System.out.println(""); } } }
@Andres-qo2zg
@Andres-qo2zg 4 жыл бұрын
Date cuenta. Yo: amiga date cuenta:v
@josef9828
@josef9828 4 жыл бұрын
asi me quedo el ejercicio : public static void main(String[] args) { int matriz1[][]=new int [3][3]; int matriz2[][]=new int [3][3]; int suma1=0; int suma2=0; int sumatotal; for (int i=0;i
@Joel19879
@Joel19879 6 жыл бұрын
package matrices; import java.util.Scanner; public class Ejercicio2SumarMatrices { public static void main(String [] args) { Scanner entrada = new Scanner(System.in); int array1 [][]=new int [3][3]; int array2 [][]=new int [3][3]; int arraySuma [][]=new int [3][3]; //LLENADO DE LOS ARRAYS System.out.println("Llenando array1........"); for(int i=0;i
@israelcruz6068
@israelcruz6068 7 жыл бұрын
Ejercicio 2: public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[][] A = new int[3][3]; int[][] B = new int[3][3]; int[][] C = new int[3][3]; System.out.println("INGRESE LOS VALORES DE LA MATRIZ A"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("("+(1+i)+","+(1+j)+"). "); A[i][j] = sc.nextInt(); } } System.out.println(" INGRESE LOS VALORES DE LA MATRIZ B"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("("+(1+i)+","+(1+j)+"). "); B[i][j] = sc.nextInt(); } } System.out.println(" SUMA DE LAS MATRICES A Y B"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { C[i][j] = A[i][j] + B[i][j]; System.out.print(C[i][j] +" "); } System.out.println(""); } }
@jonathanjoel2905
@jonathanjoel2905 7 жыл бұрын
Muy bien papa buen codigo
@lamunoz5
@lamunoz5 6 жыл бұрын
Bien!!
@artemioharoldperlaciosluqu5471
@artemioharoldperlaciosluqu5471 4 жыл бұрын
public static void main(String[] args) { int[][] matriz1=new int[3][3]; int[][] matriz2=new int[3][3]; int[][] suma=new int[3][3]; System.out.println("Digite elementos de la matriz 1:"); for(int i=0;i
@-R.G.
@-R.G. 3 жыл бұрын
/* Ejercicio 2: Crear y cargar 2 matrices de tamaño 3x3, sumarlas y mostrar su suma */ /** * * @author Mauro */ import java.util.Scanner; public class matrices2 { public static void main(String[] args) { Scanner hello= new Scanner(System.in); int matriz[][]= new int [3][3]; int s1=0,s2=0,suma_matrices=0; System.out.println("---------------------------------------"); System.out.println("INGRESO DE DATOS A LA PRIMERA MATRIZ"); System.out.println("---------------------------------------"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("Ingreso de datos ["+i+"]["+j+"]: "); matriz[i][j]=hello.nextInt(); s1+=matriz[i][j]; } } System.out.println("---------------------------------------------------"); System.out.println("INGRESO DE DATOS A LA SEGUNDA MATRIZ"); System.out.println("---------------------------------------------------"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("Ingreso de datos ["+i+"]["+j+"]: "); matriz[i][j]=hello.nextInt(); s2+=matriz[i][j]; } } suma_matrices=s1+s2; System.out.println("La suma de los datos de las matrices es: "+suma_matrices); } }
@fazdelatierra
@fazdelatierra 4 жыл бұрын
import java.util.Scanner; public class Ejercicio_02_SumaDeMatrices { public static void main(String[] args) { /* Ejercicio 2. Crear y cargar dos matrices de tamaño 3 x 3, sumarlas y mostrar su suma. */ Scanner entrada = new Scanner(System.in); int matrizA[][] = new int [3][3]; int matrizB[][] = new int [3][3]; int matrizC[][] = new int [3][3]; System.out.println("DIGITE LA MATRIZ A. "); for (int i = 0; i < 3; i ++) { for (int j = 0; j < 3; j ++) { System.out.print("Matriz A. [" + i + "][" + j + "] "); matrizA[i][j] = entrada.nextInt(); } } System.out.println("DIGITE LA MATRIZ B. "); for (int i = 0; i < 3; i ++) { for (int j = 0; j < 3; j ++) { System.out.print("Matriz B. [" + i + "][" + j + "] "); matrizB[i][j] = entrada.nextInt(); } } //System.out.println("SUMA DE MATRIZ A Y B. "); for (int i = 0; i < 3; i ++) { for (int j = 0; j < 3; j ++) { matrizC[i][j] = matrizA[i][j] + matrizB[i][j]; } } System.out.println(" MATRIZ A"); for (int i = 0; i < 3; i ++) { for (int j = 0; j < 3; j ++) { System.out.print(matrizA[i][j]); System.out.print(" "); } System.out.println(""); } System.out.println(" MATRIZ B"); for (int i = 0; i < 3; i ++) { for (int j = 0; j < 3; j ++) { System.out.print(matrizB[i][j]); System.out.print(" "); } System.out.println(""); } System.out.println(" SUMA DE AMBAS MATRICES"); for (int i = 0; i < 3; i ++) { for (int j = 0; j < 3; j ++) { System.out.print(matrizC[i][j]); System.out.print(" "); } System.out.println(""); } } }
@richardhenriquezcervantes6044
@richardhenriquezcervantes6044 2 жыл бұрын
public class Matriz_ejercicio2 { public static void main(String[] args) { Scanner ipt = new Scanner(System.in); int mat[][]; int mat2[][]; mat = new int [3][3]; mat2 = new int[3][3]; System.out.println("Digita la matriz 1: "); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("Fila: " + i + " Colunna: " + j + ": "); mat[i][j] = ipt.nextInt(); } System.out.println(""); } System.out.println("Digita la matriz 2: "); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("Fila: " + i + " Colunna: " + j + ": "); mat2[i][j] = ipt.nextInt(); } System.out.println(""); } for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("| "+ (mat[i][j] + mat2[i][j]) + " |"); } System.out.println(""); } }
@juansebastianastudillozamb2724
@juansebastianastudillozamb2724 7 жыл бұрын
Ejercicio 2 :D //Ejercicio 2 //Autor: Juan Astudillo package holamundo; import java.util.Scanner; import javax.swing.JOptionPane; public class HolaMundo { public static void main(String[] args) { //Variables int matriz1[][], matriz2[][], suma[][], nFilas, nColumnas; //Objeto Scanner Scanner in = new Scanner(System.in); //Introducir la dimension de la matrices nFilas = Integer.parseInt(JOptionPane.showInputDialog("Ingrese la cantidad de filas de las matrices: ")); nColumnas = Integer.parseInt(JOptionPane.showInputDialog("Ingrese la cantidad de columnas de las matrices: ")); //Crear las matrices matriz1 = new int[nFilas][nColumnas]; matriz2 = new int[nFilas][nColumnas]; suma = new int[nFilas][nColumnas]; //Ingresar los valores de las matrices System.out.println("Ingrese los datos de la matriz 1: "); for(int i=0; i
@wz_alex9798
@wz_alex9798 6 жыл бұрын
no hiciste el ultimo de arreglos :V
@juansebastianastudillozamb2724
@juansebastianastudillozamb2724 6 жыл бұрын
AlexS.w WorlD29 jajajajaja si, era volver a repetir lo mismo :v
@wz_alex9798
@wz_alex9798 6 жыл бұрын
lo mismo no :V un resumen de todos si :V
@ARMASAK47
@ARMASAK47 3 жыл бұрын
Scanner sc = new Scanner(System.in); int matriz1[][] = new int[3][3]; int matriz2[][] = new int[3][3]; int suma=0; System.out.println("Digite la matriz 1"); for(int i=0; i
@samuelespinoza885
@samuelespinoza885 3 жыл бұрын
veo que han hecho el ejercicio 2 muy largo les dejo el mio para que me digan si lo que hice esta mal Scanner entrada = new Scanner(System.in); int matriz[][], nFilas, nColumnas; int suma = 0; nFilas = Integer.parseInt(JOptionPane.showInputDialog("digite el numero de filas: ")); nColumnas = Integer.parseInt(JOptionPane.showInputDialog("digite el numero de columnas: ")); matriz = new int [nFilas][nColumnas]; //digitando la matiz System.out.println("Digite la matriz"); for (int i = 0; i < nFilas; i++) {//filas for (int j = 0; j < nColumnas; j++) {//columnas System.out.print("matriz ["+i+"]["+j+"]: "); matriz[i][j] = entrada.nextInt(); //sumando la matriz suma = suma + matriz[i][j]; } } //imprimiendo la matriz System.out.println(" La matriz es"); for (int i = 0; i < nFilas; i++) { for (int j = 0; j < nColumnas; j++) { System.out.print(matriz[i][j]); } System.out.println(""); } System.out.println("suma es igual a: "+suma);
@jorgereyes795
@jorgereyes795 2 жыл бұрын
Si estas mal bro, se que es tarde para contestar xd pero a lo que se refería es que la posición [0][0] tanto de la matriz 1 y 2 las vas a sumar: un ejemplo matriz 1 matriz 2 matriz12 1 2 1 2 = 2 4 3 4 3 4 6 8
@Deyver_R.
@Deyver_R. 3 жыл бұрын
package practicas; import java.util.Scanner; /** * * @author DEYVER */ public class Practicas { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner entrada=new Scanner(System.in); int matriz1[][]=new int [3][3]; int matriz2[][]=new int [3][3]; int matriz3[][]=new int [3][3]; //llenamos primer matriz for(int i=0;i
@damianfalero5229
@damianfalero5229 4 жыл бұрын
package matriz_ej2; import java.util.Scanner; public class Matriz_ej2 { public static void main(String[] args) { Scanner entrada = new Scanner(System.in); int matrizUno[][] = new int[3][3]; int matrizDos[][] = new int[3][3]; int matrizResultado[][] = new int[3][3]; //Matriz 1 System.out.println("Digite los valores para la primer matriz:"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("Matriz Uno[" + i + "][" + j + "]: "); matrizUno[i][j] = entrada.nextInt(); } } //Matriz 2 System.out.println(" Digite los valores para la segunda matriz:"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("Matriz Dos[" + i + "][" + j + "]: "); matrizDos[i][j] = entrada.nextInt(); } } //Suma for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { matrizResultado[i][j] = (matrizUno[i][j] + matrizDos[i][j]); } } //imprimiento resultado System.out.println(" Resultado de la suma:"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print("[" + matrizResultado[i][j] + "]"); } System.out.println(""); } } }
@DavidTorres-gs9kx
@DavidTorres-gs9kx 4 жыл бұрын
/* Crear y cargar dos matrices de tamaño 3x3, sumarlas y mostrar su suma */ package ejercicios_matrices; import javax.swing.JOptionPane; public class Ejercicio_02_Suma_De_Dos_Matrices { public static void main(String[] args) { int matriz1[][], matriz2[][], matriz3[][], fila, columna; fila = Integer.parseInt(JOptionPane.showInputDialog("Numero de Filas")); columna = Integer.parseInt(JOptionPane.showInputDialog("Numero de Columnas")); matriz1 = new int[fila][columna]; matriz2 = new int[fila][columna]; matriz3 = new int[fila][columna]; System.out.print("Matriz N°1"); for (int f = 0; f < fila; f++) { for (int c = 0; c < columna; c++) { matriz1[f][c] = Integer.parseInt(JOptionPane.showInputDialog("Posicion: " + f + " - " + c)); } } System.out.println(" -- Es:"); for (int i = 0; i < fila; i++) { for (int j = 0; j < columna; j++) { System.out.print(matriz1[i][j] + " | "); } System.out.println(" "); } //---------------------------------------------------------------------- JOptionPane.showMessageDialog(null, "Matriz N°2"); System.out.print("Matriz N°2"); for (int f = 0; f < fila; f++) { for (int c = 0; c < columna; c++) { matriz2[f][c] = Integer.parseInt(JOptionPane.showInputDialog("Posicion: " + f + " - " + c)); } } System.out.println(" -- Es:"); for (int i = 0; i < fila; i++) { for (int j = 0; j < columna; j++) { System.out.print(matriz2[i][j] + " | "); } System.out.println(""); } //---------------------------------------------------------------------- System.out.println("La suma de las matrices es: "); for (int f = 0; f < fila; f++) { for (int c = 0; c < columna; c++) { matriz3[f][c] = matriz1[f][c] + matriz2[f][c]; } } System.out.println(" -- Es:"); for (int i = 0; i < fila; i++) { for (int j = 0; j < columna; j++) { System.out.print(matriz3[i][j] + " | "); } System.out.println(""); } } }
@ChavyThai
@ChavyThai 10 ай бұрын
les voy a parecer un degenerado pero como me cuesta, mi codigo quedo asi: Scanner input = new Scanner(System.in); int nFilas1; int nFilas2; int nCol1; int nCol2; int iA = 0; int jA = 0; int iB = 0; int jB = 0; System.out.print("Ingrese el numero de filas de la matriz 1: "); nFilas1 = input.nextInt(); System.out.print(" ingrese el numero de columnas de la matriz 1: "); nCol1 = input.nextInt(); int[][] matriz1 = new int[nFilas1][nCol1]; System.out.println(" Ingrese los elementos de la matriz 1. "); for (iA = 0; iA < nFilas1; iA++) { for (jA = 0; jA < nCol1; jA++) { System.out.print("Matriz 1 [" + iA + "] [" + jA +"]: "); matriz1[iA][jA] = input.nextInt(); } } System.out.print(" Ingrese el numero de filas de la matriz 2: "); nFilas2 = input.nextInt(); System.out.print(" ingrese el numero de columnas de la matriz 2: "); nCol2 = input.nextInt(); int[][] matriz2 = new int[nFilas1][nCol1]; System.out.println(" Ingrese los elementos de la matriz 2."); for (iB = 0; iB < nFilas2; iB++) { for ( jB = 0; jB < nCol2; jB++) { System.out.print("Matriz 2 [" + iB + "] [" + jB +"]: "); matriz2[iB][jB] = input.nextInt(); } } System.out.println("Asi se ve la matriz 1: "); for (iA = 0; iA < nFilas1; iA++) { for (jA = 0; jA < nCol1; jA++) { System.out.print(matriz1[iA][jA]); } System.out.println(" "); } System.out.println("Asi se ve la matriz 2: "); for (iB = 0; iB < nFilas2; iB++) { for (jB = 0; jB < nCol2; jB++) { System.out.print(matriz2[iB][jB]); } System.out.println(" "); } int[][] matriz3 = {{matriz1[0][0]+matriz2[0][0], matriz1[0][1]+matriz2[0][1], matriz1[0][2]+matriz2[0][2]}, {matriz1[1][0]+matriz2[1][0], matriz1[1][1]+matriz2[1][1], matriz1[1][2]+matriz2[1][2]}, {matriz1[2][0]+matriz2[2][0], matriz1[2][1]+matriz2[2][1], matriz1[2][2]+matriz2[2][2]}}; System.out.println("La suma de las dos matrices es: "); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print(matriz3[i][j]); } System.out.println(" "); } re unga unga, pero funciono perfecto xd
@bacilicaipurresuarez2763
@bacilicaipurresuarez2763 4 жыл бұрын
import javax.swing.JOptionPane; import java.util.Scanner; public class Ejercicio2_Matriz { public static void main(String[] args) { Scanner entrada=new Scanner(System.in); int matrizA[][], matrizB[][], suma[][], nFilA, nColA, nFilB, nColB; boolean mCuadrada=true; do{ nFilA=Integer.parseInt(JOptionPane.showInputDialog("MATRIZ A Ingrese el número de Filas: ")); nColA=Integer.parseInt(JOptionPane.showInputDialog("MATRIZ A Ingrese el número de Columnas: ")); if(nFilA!=nColA){ JOptionPane.showMessageDialog(null, "La matriz no es cuadrada. Vuelve a intentarlo"); } }while(nFilA!=nColA); matrizA=new int[nFilA][nColA]; //Llenando la Matriz A System.out.println("MATRIZ A"); for(int i=0; i
@giligo4750
@giligo4750 11 ай бұрын
int numfilas, numcolum, sumprimeramatriz=0, sumsegundamatriz=0; numfilas = Integer.parseInt(JOptionPane.showInputDialog(null, "filas: ")); numcolum = Integer.parseInt(JOptionPane.showInputDialog(null, "columnas: ")); int primeramatriz[][] = new int[numfilas][numcolum]; int segundamatriz[][] = new int[numfilas][numcolum]; Scanner sc = new Scanner(System.in); System.out.println("diga los numeros de la primera matriz: "); for(int i=0; i< numfilas; i++) { for (int j = 0; j < numcolum; j++) { primeramatriz[i][j] = sc.nextInt(); sumprimeramatriz += primeramatriz[i][j]; } } System.out.println("diga los numeros de la segunda matriz: "); for(int i=0; i< numfilas; i++) { for (int j = 0; j < numcolum; j++) { segundamatriz[i][j] = sc.nextInt(); sumsegundamatriz += segundamatriz[i][j]; } } int sumatoria = sumprimeramatriz + sumsegundamatriz; System.out.println("la sumatoria de las 2: "+sumatoria);
@eduardomarcelorodriguezram6554
@eduardomarcelorodriguezram6554 3 жыл бұрын
Poco a poco aprendiendo, gracias por todas tus enseñanzas, aquí dejo la solución del ejercicio 12 package Matrices; import java.util.Scanner; /* Crear y cargar dos matrices de tamaño 3X3, sumarlas y mostrar su suma. */ public class Ejercicio3 { public static void main(String[]args){ //Lector de Datos Scanner sc = new Scanner(System.in); //Creando las matrices int matrizA[][] = new int[3][3]; int matrizB[][] = new int[3][3]; int matrizC[][] = new int[3][3]; //Ingreso de datos del usuario en las matrices System.out.println("\tINGRESO DE DATOS DEL USUARIO"); //---------- MATRIZ A---------------- System.out.println("Llenar la matriz A"); for(int i=0;i
@Gabriel-cr7xg
@Gabriel-cr7xg 3 жыл бұрын
Dudo mucho que te responda amigo, ya que falleció hace más de un año...
HOW DID HE WIN? 😱
00:33
Topper Guild
Рет қаралды 44 МЛН
THE POLICE TAKES ME! feat @PANDAGIRLOFFICIAL #shorts
00:31
PANDA BOI
Рет қаралды 25 МЛН
Nutella bro sis family Challenge 😋
00:31
Mr. Clabik
Рет қаралды 13 МЛН
One moment can change your life ✨🔄
00:32
A4
Рет қаралды 8 МЛН
55. Programación en Java || Matrices || Definición de matriz
10:33
Programación ATS
Рет қаралды 223 М.
61. Programación en Java || POO || Creación de clases y objetos
14:09
Programación ATS
Рет қаралды 768 М.
Matrices en Java (declarar y recorrer una matriz)
11:53
Cecilia Avila
Рет қаралды 22 М.
Curso Java Intermedio #30 | Suma y Resta de Matrices en Java
19:01
La Geekipedia De Ernesto
Рет қаралды 67 М.
Matriz traspuesta
8:02
Matemáticas profe Alex
Рет қаралды 1,1 МЛН
Faster than Rust and C++: the PERFECT hash table
33:52
strager
Рет қаралды 523 М.
Tutorial de algoritmos de programación | Cursos Platzi
7:03
Cheapest gaming phone? 🤭 #miniphone #smartphone #iphone #fy
0:19
Pockify™
Рет қаралды 2,2 МЛН
Опыт использования Мини ПК от TECNO
1:00
Андронет
Рет қаралды 788 М.
Samsung Galaxy 🔥 #shorts  #trending #youtubeshorts  #shortvideo ujjawal4u
0:10
Ujjawal4u. 120k Views . 4 hours ago
Рет қаралды 6 МЛН
Klavye İle Trafik Işığını Yönetmek #shorts
0:18
Osman Kabadayı
Рет қаралды 3,1 МЛН
Mastering Picture Editing: Zoom Tools Tutorial
0:52
Photoo Edit
Рет қаралды 507 М.
Clicks чехол-клавиатура для iPhone ⌨️
0:59