Answer:
class Main {
public static void fillTable(int [][] t, int or, int oc) {
for(int r=0; r<t.length; r++) {
for(int c=0; c<t[r].length; c++) {
t[r][c] = Math.max(1+Math.abs(r-or), 1+Math.abs(c-oc));
}
}
}
public static void dumpTable(int [][] t) {
for(int r=0; r<t.length; r++) {
for(int c=0; c<t[r].length; c++) {
System.out.printf("%3d", t[r][c]);
}
System.out.println();
}
}
public static void main(String[] args) {
int origin_row = 3;
int origin_col = 2;
int[][] table = new int[5][4]; // rows|cols
fillTable(table, origin_row, origin_col);
dumpTable(table);
}
}
Explanation:
Above program does not contain input handling and exception handling, but it does contain the cleverness of calculating the cell values. I'm hoping you can add the input handling yourself?
What title? or No formating
<span>When using the wait and signal operations, Wait sets the process's process control block to the blocked state and links it to the queue of processes waiting to enter this particular critical region.</span>