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 行的值,依此类推
但是它在同一行中输出所有内容,例如:
0.0 0.0 0.0 0.0
而不是
0.0 0.0(A 行)
0.0 0.0(B 行)