Problem Solving Ideas:
First, we choose to find the number of sub 7 as an example to step through the process of finding.
We then select 9 in the upper-right corner of the array.
Code implementation:
Package array; Public classQuencyarray { Public StaticBooleanFindarray(int[] arr,intNumber) {introws = arr.length;intcolumns = arr[0].length; Boolean flag =false;if(arr!=NULL&& rows>0&& columns>0){introw =0;intCol = columns-1; while(Row<rows && col>0){if(Arr[row][col]<number) {//Description of the number to be searched belowrow++; }Else if(Arr[row][col]>number) {//Description of the number to be found on the leftcol--; }Else{flag =true; Break; } } }returnFlag } Public Static void Main(string[] args) {int[] arr = {{1,2,8,9}, {2,4,9, A}, {4,7,Ten, -}, {6,8, One, the}, {8,Ten, -, -} }; System. out. println (arr, Findarray8));//trueSystem. out. println (arr, Findarray A));//false}}
For the first time, we select the upper-right corner of the array to query, and we can select the lower-left corner of the array.
Find in a two-dimensional array (Java edition)