//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();
}
}
//this way you can fill your array row by row
for (int i = 0; i < row; i++){
for (int j = 0; j < column; j++){
cin >> x;
array[i][j] = x;
}
}
// [ 1 2 3 ]
// [ 4 5 6 ]
// [ 7 8 9 ]
//this way you can fill your array column by column
for (int i = 0; i < column; i++){
for (int j = 0; j < row; j++){
cin >> x;
array[i][j] = x;
}
}
// [ 1 4 7 ]
// [ 2 5 8 ]
// [ 3 6 9 ]
int a[100000][100000];
std::fill((int*)a,(int*)a+sizeof(a)/sizeof(int),0);
// 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:
* . . * . . *
. * . * . * .
. . * * * . .
* * * * * * *
. . * * * . .
. * . * . * .
* . . * . . *
*/