_stan
Ominide
1 min. di lettura
Vota

Concetti Chiave

  • The method extracts elements from array B that are multiples of any element in array A.
  • The function takes two integer arrays as input and returns a new array.
  • Example provided: arrays A and B, with specific integers, resulting in a particular output.
  • A helper method checks if a number is a multiple of any element in an array.
  • The code structure includes a boolean function to determine multiples within an array.

Tema 30

Scrivere un metodo estraiElementiDelPrimoArrayMultipliDiQualcheElementoDelSecond che riceve in ingresso due vettori A e B di interi, e restituisce un vettore Z contenente gli elementi di B che sono multipli di qualche elemento di A. Ad esempio, siano A e B due array così costituiti
A
25 13 19 8
B
2 3 5 7 11
allora
estraiElementiDelPrimoArrayMultipliDiQualcheElementoDelSecondo( A, B) darà
25 8
 public class tema30{ // creiamo un metodo per individuare se un valore è multiplo di qualche elemento // contenuto in un array public static boolean isMultiplo (int x, int[] V){ boolean esito = false; for (int i = 0; i 

Domande e risposte

Hai bisogno di aiuto?
Chiedi alla community