+ 5
Continue in same way... For 1) : you need to find -10, 19 locations? Same way use 2 loops and find. 2) Initially set min = ar[0][0]; and max = 0; Change current element is less then overide to min , and greater than max then override max. And Locations as minR, maxR, minC, maxC. 3) You can't delete from arrays in java as it is static data structure. You can copy to new array or skip when printing in the output . Pls Show your attempt if not successful.. hope it helps... edit: Each will same just some changes ..
4th Dec 2022, 5:28 PM
Jayakrishna 🇼🇳
+ 5
You will need to create a new matrix if you need to delete rows and colums. Maybe this helps: https://stackoverflow.com/questions/1805147/how-to-remove-a-row-from-a-2d-array
4th Dec 2022, 5:32 PM
Denise Roßberg
Denise Roßberg - avatar
+ 4
John When you found min and max -> store columnMax and columnMin. if(arr[i][j] > maxValue){ maxValue = arr[i][j]; columnMax = i; } i is the index of the outer loop, j the index of the inner loop: -> i is for the columns -> j is for the rows (Maybe it is better to use column and row as name instead of i and j). Do the same for minValue. Now you just swap the arrays of your array, like you would do with other variables: int[] temp = arr[columnMax]; arr[columnMax] = arr[columnMin]; arr[columnMin] = temp;
5th Dec 2022, 2:45 PM
Denise Roßberg
Denise Roßberg - avatar
+ 3
John It's actually I already mentioned. I edited, see again my first post. You can't delete from array. Copy to new array, by skipping the row and column values which includes max, min values. For example : -10 is at i=0, j = 2 so skip when I=0 or j = 2 while in looping... (Entire 0th row and 2 column ).. You can copy or just print on the output, if no need to store in array..
4th Dec 2022, 5:48 PM
Jayakrishna 🇼🇳