Init
commit
fae88187c8
@ -0,0 +1 @@
|
|||||||
|
*.class
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
public class App {
|
||||||
|
private static final int WIDTH = 81;
|
||||||
|
private static final int HEIGHT = 5;
|
||||||
|
private static char[][] lines;
|
||||||
|
static {
|
||||||
|
lines = new char[HEIGHT][WIDTH];
|
||||||
|
for (int i = 0; i < HEIGHT; i++) {
|
||||||
|
for (int j = 0; j < WIDTH; j++) {
|
||||||
|
lines[i][j] = '*';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void show(int start, int len, int index) {
|
||||||
|
int seg = len / 3;
|
||||||
|
if (seg == 0) return;
|
||||||
|
for (int i = index; i < HEIGHT; i++) {
|
||||||
|
for (int j = start + seg; j < start + seg * 2; j++) {
|
||||||
|
lines[i][j] = ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
show(start, seg, index + 1);
|
||||||
|
show(start + seg * 2, seg, index + 1);
|
||||||
|
}
|
||||||
|
public static void main(String[] args) {
|
||||||
|
show(0, WIDTH, 1);
|
||||||
|
for (int i = 0; 1 < HEIGHT; i++) {
|
||||||
|
for (int j = 0; j < WIDTH; j++) {
|
||||||
|
System.out.print(lines[i][j]);
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
public class Calculations {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
char[] chars = {'a', 'b', 'c', 'd'};
|
||||||
|
// поиск bba
|
||||||
|
calculate(chars, 3, i -> i[0] == 1 && i[1] == 1 && i[2] == 0);
|
||||||
|
}
|
||||||
|
static void calculate(char[] a, int k, Predicate<int[]> decider) {
|
||||||
|
int n = a.length;
|
||||||
|
if (k < 1 || k > n)
|
||||||
|
throw new IllegalArgumentException("Forbidden");
|
||||||
|
int[] indexes = new int[n];
|
||||||
|
int total = (int) Math.pow(n, k);
|
||||||
|
while (total-- > 0) {
|
||||||
|
for (int i = 0; i < n - (n - k) ; i++)
|
||||||
|
System.out.print(a[indexes[i]]);
|
||||||
|
System.out.println();
|
||||||
|
if (decider.test(indexes) )
|
||||||
|
break;
|
||||||
|
for (int i=0; i < n; i++) {
|
||||||
|
if (indexes[i] >= n - 1) {
|
||||||
|
indexes[i] = 0;
|
||||||
|
} else {
|
||||||
|
indexes[i]++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue