
Comparar dos Arreglos y mostrar los elementos en común
Java
Publicado el 25 de Mayo del 2020 por Luu
1.360 visualizaciones desde el 25 de Mayo del 2020
Crear un método que reciba como parámetro dos arreglos y muestre los elementos en común




difParesImpares(0, 10); // 5
difParesImpares(0, 1); // -1
difParesImpares(10, 20); // 15






(1)







(1)1
4 1
9 4 1
16 9 4 1
25 16 9 4 1
36 25 16 9 4 1
49 36 25 16 9 4 1
64 49 36 25 16 9 4 1
81 64 49 36 25 16 9 4 1
100 81 64 49 36 25 16 9 4 1






(1)trianguloInvertido(5) # [[5, 4, 3, 2, 1], [5, 4, 3, 2], [5, 4, 3], [5, 4], [5]]
print("\n".join(map(str, trianguloInvertido(5))))
[5, 4, 3, 2, 1]
[5, 4, 3, 2]
[5, 4, 3]
[5, 4]
[5]
print("\n".join(map(lambda x: " ".join(map(str, x)), trianguloInvertido(5))))
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5
print(trianguloInvertidoDecreciente(5)) # [[5, 4, 3, 2, 1], [4, 3, 2, 1], [3, 2, 1], [2, 1], [1]]
print("\n".join(map(str, trianguloInvertidoDecreciente(5))))
[5, 4, 3, 2, 1]
[4, 3, 2, 1]
[3, 2, 1]
[2, 1]
[1]
print("\n".join(map(lambda x: " ".join(map(str, x)), trianguloInvertidoDecreciente(5))))
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1

IntToString([[5, 4, [3, [2], 1]], [5, 4, []], [5, [4]]]) # [['5', '4', ['3', ['2'], '1']], ['5', '4', []], ['5', ['4']]]

IntToString([1, 2, 3, 4]) # ['1', '2', '3', '4']
IntToString([1, 2, 3.5, 4.7]) # ['1', '2', '3.5', '4.7']