///
import javax.swing.JOptionPane; public class A001 { public static void main(String[] args) { int[][] v = {{1, 10, 8}, {15, 40, 16}, {10, 33, 91}, {0, 44, 51}}; int d=Integer.parseInt(JOptionPane.showInputDialog("Digite um valor")); System.out.print(f(v, 3, 2, d)); } public static boolean f(int[][] valores, int n, int m, int x) { int i, j, cont, p, q; boolean a; a = false; i = 0; while (i <= n && !a) { j = 0; while (j <= m && !a) { if (valores[i][j] == x) { a = true; } j = j + 1; } i = i + 1; } return a; } }
Se a instrução System.out.print(f(v, 3, 2, d)); for alterada para System.out.print(f(v, 2, 3, d)); e para a variável d for fornecido o valor 51, quando o programa for executado