You are viewing a single comment's thread. Return to all comments →
how to store X in int array
You can't. What you can do is, do the comparisons and output at the same time, so when you find a cavity, output an X instead of the digit. While you could have read the input as characters and compared and assigned the X, using integers is generally easier to understand, so I would prefer reading the input as integer. But if you want to stick to keeping the processing and output separate, use a 2D character array.
Why would one store X if you can store a sentinel value(say Integer.MAX_INT), and print X while printing, when a sentinel is encountered
make it string array
I suggest you to change the number when their is any cavity to any negative number (let us change cavity a[i][j] to value -1) and then while printing you print the value 'X' in place of that negative number.