
ver si un arreglo esta dentro del otro
Publicado por quique farro (1 intervención) el 10/06/2015 01:09:24
SERIAN TAN AMABLES DE EXPLICARME ESTE CODIGO?, SOLO SE QUE ES PARA VER SI UN AREGLO ESTA DENTRO DEL OTRO LO QUE NO ENTIENDO MUY BIEN SON LAS ASIGNACIONES
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* @author farro
*/
public class Practica5 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int a[]={2,1,8,7};
int b[][]={
{2,1,8,7},
{4,3,6,5},
{6,5,4,3},
{8,7,2,1},
};
int num=0;
int i,j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
if (b[i][j]==a[j]) {
num++;
}
}
}
if (num==4) {
System.out.println("El arreglo de una dimensión si se encuentra en el arreglo de dos dimensiones.");
}
else {
System.out.println("El arreglo de una dimensión no se encuentra en el arreglo de dos dimensiones.");
}
}
}
Valora esta pregunta


0