如果您看到我在下面的矩阵中保留的数字是根据我的清单,还有所有这些数字,并且当我尝试打印清单时,只需发送给我很多这些清单: 我@ 7852e922这是内存地址?并且如果打印的对象。感谢您的关注。无法打印我的清单
package estructurasDeDatos;
import java.util.List;
import java.util.LinkedList;
public class Matriz {
private static Scanner read;
public static void main(String[] args){
/*read = new Scanner(System.in);
System.out.println("Ingrese el numero de filas y columnas: ");
int f = read.nextInt();
int c = read.nextInt();*/
LinkedList ll = new LinkedList();
System.out.println(" ** ** *** ******* **** ***** *** ***** ***** ");
System.out.println(" * ** * * * * * * * * * * ");
System.out.println(" * ** * * * * * * * * * * ");
System.out.println(" * * ******* * **** * * *** **** ");
System.out.println(" * * * * * * * * * * * ");
System.out.println(" * * * * * * * * * * * ");
System.out.println(" * * * * * * * ***** *** ***** ***** ");
System.out.println("###########################################################################");
int mt [][] = new int[10][10];//Genero la matriz con dos arreglos con una cantidad que yo quiera de
//filas y columnas.
int num;
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{//Genero un numero aleatorio entre 0 y 100
num=(int)(Math.random()*100);
//Asigno el numero generado a la matriz
mt[i][j]=num;
ll.push(mt);
}
}
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{//Imprimo la celdad de la matriz
System.out.print(mt[i][j]+"\t");
}
System.out.println();
}
System.out.println("###########################################################################");
System.out.println("\n\n");
System.out.println("LOS NUMEROS DE LA DIAGONAL PRINCIPAL:");
System.out.print(mt[0][0]+" "+mt[1][1]+" "+mt[2][2]+" "+mt[3][3]+" "+mt[4][4]+" "+mt[5][5]+" "+mt[6][6]+" "+mt[7][7]+" "+mt[8][8]+" "+mt[9][9]+"\n\n");
int sumatoriadiap=mt[0][0]+mt[1][1]+mt[2][2]+mt[3][3]+mt[4][4]+mt[5][5]+mt[6][6]+mt[7][7]+mt[8][8]+mt[9][9];
System.out.println("La sumatoria de la diagonal principal es: \n"+sumatoriadiap);
System.out.println("El promedio de la diagonal principal es : \n"+sumatoriadiap/10);
////////////////////////////////////////////////////////////////////////////////////////////////////////
System.out.println("LOS NUMEROS DE LA DIAGONAL SECUNDARIA:");
System.out.print(mt[0][9]+" "+mt[1][8]+" "+mt[2][7]+" "+mt[3][6]+" "+mt[4][5]+" "+mt[5][4]+" "+mt[6][3]+" "+mt[7][2]+" "+mt[8][1]+" "+mt[9][0]+"\n\n");
int sumatoriadias=mt[0][9]+mt[1][8]+mt[2][7]+mt[3][6]+mt[4][5]+mt[5][4]+mt[6][3]+mt[7][2]+mt[8][1]+mt[9][0];
System.out.println("La sumatoria de la diagonal principal es: \n"+sumatoriadias);
System.out.println("El promedio de la diagonal principal es : \n"+sumatoriadias/10);
}
}
对于初学者来说,我没有看到你在哪里”重新列印清单。另外,你正在处理没有'toString()'重写的数组 - 你看到的是数组的哈希码。第三,你的链表没有类型,这使得它工作......有趣...... – Makoto 2014-09-20 06:54:04