fork download
  1. import java.util.*;
  2. import java.io.*;
  3.  
  4.  
  5. public class Main
  6. {
  7. static boolean visit[];
  8. static Random rd = new Random();
  9. public static void main (String[] args) throws IOException
  10. {
  11. for(int i = 0 ; i < 6 ; i++){
  12. visit = new boolean[46];
  13. lotto("", 0, visit);
  14. }
  15. }
  16. public static void lotto(String str, int cnt, boolean[] boolarr){
  17. if(cnt == 6){
  18. System.out.println(str);
  19. return;
  20. }
  21.  
  22. int num = rd.nextInt(45)+1;
  23.  
  24. if(!boolarr[num]){
  25. boolarr[num] = true;
  26. lotto(str+" "+Integer.toString(num), cnt+1, boolarr);
  27. }else{
  28. lotto(str, cnt, boolarr);
  29. }
  30. }
  31. }
Success #stdin #stdout 0.11s 57792KB
stdin
Standard input is empty
stdout
 19 33 32 3 8 7
 29 10 32 16 18 43
 2 10 34 13 6 18
 39 4 20 16 18 3
 7 25 38 20 24 23
 43 20 23 30 21 36