fork(2) download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. class Main
  5. {
  6. static int k = 4;
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9.  
  10. new Main().test7(k, "");
  11. }
  12.  
  13. void test7(int i, String a) {
  14.  
  15. a = a + "0";
  16.  
  17. if (a.length() == k) {
  18. System.out.println(""+a);
  19. a = a.substring(0, a.length()-1);
  20. a =a +"1";
  21. System.out.println(a);
  22. }else {
  23. test7(i-1, a);
  24. if (a.length() >1) {
  25. a =a.substring(0, a.length()-1);
  26. a =a+"1";
  27. } else {
  28. a = "1";
  29. }
  30. test7(i-1,a);
  31. }
  32.  
  33. }
  34.  
  35. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111