Fill 2 Dimensional Array With Value

[Solved] Fill 2 Dimensional Array With Value | Vb - Code Explorer | yomemimo.com
Question : fill a two dimensional array with default value

Answered by : fantastic-falcon-t69ggsqxtzr0

for (double[] row: matrix) Arrays.fill(row, 1.0);

Source : | Last Update : Fri, 12 Jun 20

Question : fill two dimensional array

Answered by : kos-pter

//this way u can fill your array row by row
Scanner input = new Scanner(System.in);
for (int i = 0; i < row; i++){	for (int j = 0; j < column; j++){ array[i][j] = input.nextInt();	}
}
//this way u can fill your array column by column
//Scanner input = new Scanner(System.in);
for (int i = 0; i < column; i++){	for (int j = 0; j < row; j++){ array[i][j] = input.nextInt();	}
}

Source : | Last Update : Sat, 28 May 22

Question : Fill 2-dimensional array with value

Answered by : amused-ant-ms2zfw4jsx3t

int a[100000][100000];
std::fill((int*)a,(int*)a+sizeof(a)/sizeof(int),0);

Source : https://stackoverflow.com/questions/46076676/to-set-default-value-of-2d-array-in-c | Last Update : Wed, 12 May 21

Question : Fill two dimensional array

Answered by : dane

// To fill two dimenional array with some simbol, e.g. "*"
Scanner scanner = new Scanner(System.in);
int number = scanner.nextInt();
String[][] matrix = new String[number][number];
for (String[] strings : matrix) { Arrays.fill(strings, ".");
}
// To modify only middle and/or diagonales:
for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[i].length; j++) { if (i == number / 2) { matrix[i][j] = "*"; } if (j == number / 2) { matrix[i][j] = "*"; } if (i == j) { matrix[i][j] = "*"; } if (i == number - j - 1) { matrix[i][j] = "*"; } }
}
/*
Result:
* . . * . . *
. * . * . * .
. . * * * . .
* * * * * * *
. . * * * . .
. * . * . * .
* . . * . . *
*/

Source : | Last Update : Wed, 20 Jul 22

Answers related to fill 2 dimensional array with value

Code Explorer Popular Question For Vb