Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shavit Borisov
- // CW
- public class PartiallySortedMatrix
- {
- static int[][] matrix;
- public PartiallySortedMatrix(int[][] matrix)
- {
- this.matrix = matrix.clone();
- }
- public static void searchValue(int value)
- {
- int col;
- for(int i = 0; i < matrix.length; i++)
- {
- col = findKey(matrix, i, value);
- if(col != -1)
- System.out.printf("%d was found in matrix[%d][%d]", value, i, col);
- }
- }
- public static int findKey(int[][] array, int row, int key)
- {
- for(int i = 0; i < array[row].length; i++)
- {
- if(array[row][i] > key)
- break;
- else if(array[row][i] == key)
- return i;
- }
- return -1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement