Created by kirillkaumov on 09 10 14 public class MyClass static int en

 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
39
40
41
42
43
44
45
46
47
48
49
/**
* Created by kirillkaumov on 09/10/14.
*/
public class MyClass {
static int entity = 1;
public static void main(String[] args) {
int[] a = {1, 1, 1, 1, 1};
int[] cur = {0, 1, 1, 1, 1};
print(a);
print(cur);
while (!check(a, cur)) {
tact(cur);
print(cur);
}
}
static boolean check(int[] a, int[] cur) {
int index = 0;
while (index < a.length) {
if (a[index] != cur[index]) {
return false;
}
index++;
}
return true;
}
static void tact(int[] cur) {
int res = (cur[cur.length - 1] + cur[cur.length - 2]) % 2;
int index = cur.length - 1;
while (index > 0) {
cur[index] = cur[index - 1];
index--;
}
cur[0] = res;
}
static void print(int[] cur) {
System.out.print(entity + ". ");
for (int element : cur) {
System.out.print(element + " ");
}
System.out.println();
entity++;
}
}