-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImprimirConfigurarLeerMatrices.java
More file actions
71 lines (49 loc) · 1.85 KB
/
ImprimirConfigurarLeerMatrices.java
File metadata and controls
71 lines (49 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import java.util.Scanner;
public class ImprimirConfigurarLeerMatrices {
static int matriz1[][] = null;
static int matriz2[][] = null;
static Scanner scanner = new Scanner(System.in);
public static int[][] definirTamaño(int[][] x) {
System.out.println("ingrese el tamaño de la matriz Filas&Columnas");
String datosIngresados = scanner.next();
String[] datos = datosIngresados.split("&");
int filas = Integer.parseInt(datos[0]);
int columnas = Integer.parseInt(datos[1]);
x = new int[filas][columnas];
return x;
}
public static void ingresarValores(int[][] x) {
System.out.println("ingresen valores de la matriz");
for (int i = 0; i < x.length; i++) {
for (int j = 0; j < x[i].length; j++) {
x[i][j] = Integer.parseInt(scanner.next());
}
}
}
public static void ImprimirMatriz(int[][] x) {
System.out.println("ingresen valores de la matriz");
for (int i = 0; i < x.length; i++) {
for (int j = 0; j < x[i].length; j++) {
System.out.print(x[i][j]);
System.out.print(",");
}
System.out.println();
}
}
public static void main(String[] args) {
matriz1 = definirTamaño(matriz1);
System.out.println("Filas: " + matriz1.length);
System.out.println("Columnas: " + matriz1[0].length);
System.out.println();
ingresarValores(matriz1);
System.out.println();
ImprimirMatriz(matriz1);
matriz2 = definirTamaño(matriz2);
System.out.println("Filas: " + matriz2.length);
System.out.println("Columnas: " + matriz2[0].length);
System.out.println();
ingresarValores(matriz2);
System.out.println();
ImprimirMatriz(matriz2);
}
}