rowsTotal = new double[rows];
positions = new double [rows][];
for(index = 0; index < rows; index++){
System.out.print("Please enter number of positions in row " + (char)(index+65) + " : ");
pos = keyboard.nextInt();
if(pos > MAX_POSITIONS){
System.out.print("ERROR: Out of range, try again: ");
pos = keyboard.nextInt();
}
positions[index] = new double[pos];
}
System.out.print("(A)dd, (R)emove, (P)rint, e(X)it : ");
input = keyboard.next().charAt(0);
input = Character.toUpperCase(input);
if(input == 'P'){
for(int index1= 0; index1 < rows; index1++){
for(int pos1= 0; pos1 < pos; pos1++){
System.out.print(positions[index1][pos1] + " ");
}
}
}
我想要的输出将其显示为为每一行的矩阵,所以对于第一行,这将是用于行A中的值,并且在第二行。将用于行B上的值,等等等等为什么我的数组不能在2d中打印?
但其输出它全部在同一行中,如:
0.0 0.0 0.0 0.0
而非
0.0 0.0(行A)
0.0 0.0(B行)
哈,非常感谢。多么愚蠢的错误。 – NickP
@NickP很高兴帮助。请记住,你可以提出一个你认为有帮助的答案,或者甚至接受那个你认为解决了你的问题的答案。 –
我很乐意回复一个答案,但它需要15个声望点。 – NickP