Si no les gusta bucle, el uso de la recursividad :)
public static void test1() {
class Chk {
boolean c(int [] b, int val, int pos) {
if (pos >= b.length) {
return true;
}
if (b[pos] != val) {
return false;
}
return c(b, val, pos + 1);
}
}
Chk test = new Chk();
System.out.println(test.c(new int [] {0xff, 0xff}, 0xff, 0));
System.out.println(test.c(new int [] {0xff, 0xff, 0xff, 0xfe}, 0xff, 0));
System.out.println(test.c(new int [] {0x01, 0x01, 0x01, 0x01}, 0xff, 0));
System.out.println(test.c(new int [] {0x01, 0x01, 0x01, 0x01}, 0x01, 0));
}
bien en C que se p ... .. oh sí, esto es Java :) Lamentablemente, No creo que eso sea posible (+1 para el elemento similar a la lista de deseos). –
sin bucles ?? ¡¡No!! – WickeD
@JacoVanNiekerk: ¿cómo lo harías en C sin bucle? La única forma en que podría pensar requeriría 'b' ser de tamaño fijo y" pequeño ". –