Мне нужна помощь в заполнении 2D-массива с использованием вложенного цикла for.Желаемый результат: ...
20,0 19,0 18,0 17,0 16,0 15,0 14,0 13,0 12,0 11,0 10,0 11,0 12,0 13,0 14,0 15,0 16,0 17,0,0 18,0 19,0 20,0
19,0 18,0 17,0 16,0 15,0 14,0 13,0 12,0 11,010,0 9,0 10,0 11,0 12,0 13,0 14,0 15,0 16,0 17,0,0 18,0 19,0
18,0 17,0 16,0 15,0 14,0 13,0 12,0 11,0 10,0 9,0 8,0 9,0 10,0 11,0 12,0 13,0 14,0 15,0 16,0 17,0 18,0
17,0 16,0 15,0 14,0 13,012,0 11,0 10,0 9,0 8,0 7,0 8,0 9,0 10,0 11,0 12,0 13,0 14,0 15,0 16,0 17,0 16,0
16,0 15,0 14,0 13,0 12,0 11,0 10,0 9,0 8,0 7,0 6,0 7,0 8,0 9,0 10,0 11,0 12,0 13,0 14,0 15,0 16,0
15,014,0 13,0 12,0 11,0 10,0 9,0 8,0 7,0 6,0 5,0 6,0 7,0 8,0 9,0 10,0 11,0 12,0 13,0 14,0 15,0
14,0 13,0 12,0 11,0 10,0 9,0 8,0 7,0 6,0 5,0 4,0 5,0 6,0 7,0 8,0 9,0 10,0 11,0 12,0 13,0 14,0
13,0 12,0 11,0 10,0 9,0 8,0 7,0 6,0 5,0 4,0 4,0 5,0 6,0 7,0 8,0 9,0 10,0 11,0 12,0 13,0
12,0 11,0 10,0 9,0 8,0 7,0 6,0 5,0 4,0 3,0 3,0 4,0 5,0 6,0 7,0 8,09,0 10,0 11,0 12,0
11,0 10,0 9,0 8,0 7,0 6,0 5,0 4,0 3,0 1,0 1,0 2,0 4,0 5,0 6,0 7,0 8,0 9,0 10,0 11,0
10,0 9,0 8,0 7,0 6,0 5,0 4,0 3,0 1,0 0,0 1,0 1,0 2,03.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0
11.0 10.0 9.0 8.0 7.0 6.0 5.0 4.0 3.0 2.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0
12.0 11.0 10.0 9.0 8.0 7.0 6.0 5.0 4.03,0 2,0 4,0 5,0 6,0 7,0 8,0 9,0 10,0 11,0 12,0
13,0 12,0 11,0 10,0 9,0 8,0 7,0 6,0 5,0 4,0 3,0 4,0 6,0 7,0 8,0 9,0 10,0 11,0 12,0 13,0
14,0 13,0 12,0 11,0 10,09,0 8,0 7,0 6,0 5,0 4,0 5,0 6,0 7,0 8,0 9,0 10,0 11,0 12,0 13,0 14,0
15,0 14,0 13,0 12,0 11,0 10,0 9,0 8,0 7,0 6,0 5,0 6,0 7,0 8,0 9,0 10,0 11,0 12,0 13,0 14,0 15,0
16,015,0 14,0 13,0 12,0 11,0 10,0 9,0 8,0 7,0 6,0 7,0 8,0 9,0 10,0 11,0 12,0 13,0 14,0 15,0 16,0
17,0 16,0 15,0 14,0 13,0 12,0 11,0 10,0 9,0 8,0 7,0 8,0 9,0 10,0 11,0 12,0 13,0 14,0 15,0 16,0 17,0,0 1037 *
18,0 17,0 16,0 15,0 14,0 13,012,0 11,0 10,0 9,0 8,0 9,0 10,0 11,0 12,0 13,0 14,0 15,0 16,0 17,0 18,0
19,0 18,0 17,0 1,0 16,0 15,0 14,0 13,0 12,0 11,0 10,0 9,0 10,0 11,0 12,0 13,0 14,0 15,0 16,0 17,0,0 18,0 19,0
20,0 19,018,0 17,0 16,0 15,0 14,0 13,0 12,0 11,0 10,0 11,0 12,0 13,0 14,0 15,0 16,0 17,0 18,0 19,0 20,0
Это мой код для заполнения массива ...
int row;
int column;
int counter=10;
int counter1=10;
for( row =0; row<array.length; row++) {
array[row][0] = obj.getZ(10,counter);
counter--;
for( column =0; column<array[row].length; column++) {
array[row][column] = obj.getZ(counter1,10);
counter1 --;
Я уже объявил массивбыть 20 на 20, а obj.getZ просто вызывает этот метод ...
public double getZ(double x, double y) {
double z=(Math.abs(x)+Math.abs(y));
return z;
Массив - это значение z, которое формируется из абсолютных значений x и y.