Concetti Chiave

  • The method checks if any element of the vector is present in the matrix, returning TRUE if none are found.
  • The input consists of a matrix M and a vector V, which the method examines.
  • If an element of the vector is found in the matrix, the method returns FALSE immediately.
  • The method iterates through both the array and the matrix to perform the check.
  • Example given: if vector elements are 20, 30, 40, 50, 60 and absent in the matrix, the method returns TRUE.

Tema 67

Scrivere un metodo verificaCheNessunElementoDelVettoreSiaPresenteNellaMatrice che riceve in ingresso una matrice M ed un vettore V e restituisce TRUE se nessun elemento del vettore presente nella matrice; FALSE altrimenti.

Ad esempio, siano M e V rispettivamente una matrice e un vettore cos costituiti

0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
20 30 40 50 60
allora verificaCheNessunElementoDelVettoreSiaPresenteNellaMatrice (M, V) = TRUE

 public class tema67{ public static boolean verificaCheNessunElementoDelVettoreSiaPresenteNellaMatrice (int[][] M, int[] V){ // in questo caso baster scorrere larray e la matrice e appena un elemento // dellarray dovesse trovarsi // nella matrice far restituire false for (int k = 0; k    

Domande da interrogazione

  1. Come funziona il metodo per determinare la presenza di elementi del vettore nella matrice?
  2. Il metodo scorre gli elementi del vettore e della matrice; se un elemento del vettore viene trovato nella matrice, restituisce FALSE immediatamente.

  3. Qual è un esempio di input per cui il metodo restituirebbe TRUE?
  4. Se la matrice M è composta da numeri da 0 a 15 e il vettore V contiene i numeri 20, 30, 40, 50, 60, il metodo restituirebbe TRUE poiché nessun elemento del vettore è presente nella matrice.

Domande e risposte

Hai bisogno di aiuto?
Chiedi alla community