2025-10-28 22:10:22 -06:00
|
|
|
public class Test_3{
|
2025-10-28 23:08:54 -06:00
|
|
|
public boolean search(int [][] matrix, int to_search){
|
2025-10-28 22:10:22 -06:00
|
|
|
for(int i = 0; i < matrix.lenght; i++){
|
|
|
|
|
for(int j = 0; j < matrix[i].legth; j++) {
|
|
|
|
|
if (matrix[i][j] == to_search){
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
|
2025-10-28 23:08:54 -06:00
|
|
|
public static void main(String[] args){
|
|
|
|
|
Test_3 ojb = new Test_3();
|
|
|
|
|
int[][] data = new int[][] {
|
2025-10-28 22:10:22 -06:00
|
|
|
{1,2,3},
|
|
|
|
|
{22,42,45},
|
|
|
|
|
{38,26,16}}, 42);
|
2025-10-28 23:08:54 -06:00
|
|
|
};
|
|
|
|
|
boolean result = obj.search(data, 420;
|
|
|
|
|
System.out.println("Found: " + result);
|
|
|
|
|
|
2025-10-28 22:10:22 -06:00
|
|
|
|