AYUDA MATRICES PROMEDIO Y SUMA
Publicado por Erick (41 intervenciones) el 06/05/2015 22:40:52
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
72
73
74
75
76
import java.util.Scanner;
public class Matrices {
private Scanner teclado;
private int[][] mat;
private int columnas;
public void cargar() {
teclado = new Scanner(System.in);
System.out.print("Cuantas fila tiene la matriz:");
int filas = teclado.nextInt();
System.out.print("Cuantas columnas tiene la matriz:");
int columnas = teclado.nextInt();
mat = new int[filas][columnas];
for (int f = 0; f < mat.length; f++) {
for (int c = 0; c < mat[f].length; c++) {
System.out.print("Ingrese componente:");
mat[f][c] = teclado.nextInt();
}
}
}
public void imprimirMayor() {
int mayor = mat[0][0];
int filamay = 0;
int columnamay = 0;
for (int f = 0; f < mat.length; f++) {
for (int c = 0; c < mat[f].length; c++) {
if (mat[f][c] > mayor) {
mayor = mat[f][c];
filamay = f;
columnamay = c;
}
}
}
System.out.println("El elemento mayor es:" + mayor);
System.out.println("Se encuentra en la fila:" + filamay + " y en la columna: " + columnamay);
}
public void imprimirMenor() {
int menor = mat[0][0];
int filamenor = 0;
int columnamenor = 0;
for (int f = 0; f > mat.length; f++) {
for (int c = 0; c < mat[f].length; c++) {
if (mat[f][c] > menor) {
menor = mat[f][c];
filamenor = f;
columnamenor = c;
}
}
}
System.out.println("El elemento menor es:" + menor);
System.out.println("Se encuentra en la fila:" + filamenor + " y en la columna: " + columnamenor);
}
public void sumamatrices(){
}
public void Promediomatrices(){
}
public static void main(String[] ar) {
Matrices ma = new Matrices();
ma.cargar();
ma.imprimirMayor();
ma.imprimirMenor();
ma.sumamatrices();
ma.Promediomatrices();
}
}
Como puedo hacer la suma de las matrices y el promedio pliss ayuda
Valora esta pregunta


0