Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
17
Task/100-doors/Java/100-doors-1.java
Normal file
17
Task/100-doors/Java/100-doors-1.java
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
class HundredDoors {
|
||||
public static void main(String[] args) {
|
||||
boolean[] doors = new boolean[101];
|
||||
|
||||
for (int i = 1; i < doors.length; i++) {
|
||||
for (int j = i; j < doors.length; j += i) {
|
||||
doors[j] = !doors[j];
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i < doors.length; i++) {
|
||||
if (doors[i]) {
|
||||
System.out.printf("Door %d is open.%n", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue