Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
21
Task/Man-or-boy-test/Java/man-or-boy-test-1.java
Normal file
21
Task/Man-or-boy-test/Java/man-or-boy-test-1.java
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import java.util.function.DoubleSupplier;
|
||||
|
||||
public class ManOrBoy {
|
||||
|
||||
static double A(int k, DoubleSupplier x1, DoubleSupplier x2,
|
||||
DoubleSupplier x3, DoubleSupplier x4, DoubleSupplier x5) {
|
||||
|
||||
DoubleSupplier B = new DoubleSupplier() {
|
||||
int m = k;
|
||||
public double getAsDouble() {
|
||||
return A(--m, this, x1, x2, x3, x4);
|
||||
}
|
||||
};
|
||||
|
||||
return k <= 0 ? x4.getAsDouble() + x5.getAsDouble() : B.getAsDouble();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(A(10, () -> 1.0, () -> -1.0, () -> -1.0, () -> 1.0, () -> 0.0));
|
||||
}
|
||||
}
|
||||
27
Task/Man-or-boy-test/Java/man-or-boy-test-2.java
Normal file
27
Task/Man-or-boy-test/Java/man-or-boy-test-2.java
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
public class ManOrBoy {
|
||||
interface Arg {
|
||||
public int run();
|
||||
}
|
||||
|
||||
public static int A(final int k, final Arg x1, final Arg x2,
|
||||
final Arg x3, final Arg x4, final Arg x5) {
|
||||
if (k <= 0)
|
||||
return x4.run() + x5.run();
|
||||
return new Arg() {
|
||||
int m = k;
|
||||
public int run() {
|
||||
m--;
|
||||
return A(m, this, x1, x2, x3, x4);
|
||||
}
|
||||
}.run();
|
||||
}
|
||||
public static Arg C(final int i) {
|
||||
return new Arg() {
|
||||
public int run() { return i; }
|
||||
};
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(A(10, C(1), C(-1), C(-1), C(1), C(0)));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue