Ayuda con matrices en Java
Publicado por Joel Garza (1 intervención) el 29/11/2009 20:35:38
Bueno tengo un pequenio problema, el problema es que no se como puedo pedirle al usuario que introduzca el tamanio de la matriz que desee. De antemano gracias. Aqui les dejo el codigo:
public class Matriz{
public int n;
public double [ ][ ]x;
public Matriz(int n) {
this.n=n;
x = new double [n][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
x[i][j] = 0.0;
}
}
}
public Matriz(double[ ][ ] y) {
this.x = y;
n = y.length;
public class Ejecucion {
public static void main(String args []) {
String option = " ";
int opt = 0;
double [][]a_1 = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
Matriz a = new Matriz(a_1);
double [][]b_1 = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
Matriz b = new Matriz(b_1);
public class Matriz{
public int n;
public double [ ][ ]x;
public Matriz(int n) {
this.n=n;
x = new double [n][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
x[i][j] = 0.0;
}
}
}
public Matriz(double[ ][ ] y) {
this.x = y;
n = y.length;
public class Ejecucion {
public static void main(String args []) {
String option = " ";
int opt = 0;
double [][]a_1 = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
Matriz a = new Matriz(a_1);
double [][]b_1 = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
Matriz b = new Matriz(b_1);
Valora esta pregunta


0