fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Random gera = new Random();
  13. int linha = 2;
  14. int coluna = 42;
  15. int[][] numAle = new int [linha][coluna];
  16. ArrayList<Integer> num = new ArrayList<>(linha * coluna);
  17.  
  18. for(int j = 0; j < (linha * coluna); j++)
  19. {
  20. num.add(j);
  21. }
  22.  
  23. for (int i = 0 ; i < numAle.length ; i++)
  24. {
  25. for (int j = 0 ; j<numAle[i].length ; j++)
  26. {
  27. int index = gera.nextInt(num.size());
  28. numAle[i][j] = num.get(index);
  29. num.remove(index);
  30. }
  31. }
  32.  
  33. System.out.println (" Imprimindo resultados");
  34. System.out.println ("==============================================");
  35.  
  36.  
  37. for (int i = 0 ; i < numAle.length ; i++)
  38. {
  39. for (int j = 0 ; j < numAle[i].length ; j++)
  40. {
  41. System.out.printf("%2d ", numAle[i][j]);
  42.  
  43. }
  44. System.out.println ("");
  45. }
  46. }
  47. }
Success #stdin #stdout #stderr 0.04s 711168KB
stdin
Standard input is empty
stdout
            Imprimindo resultados
==============================================
22 52 44 25 71 80 59 76 65 75 77  4 40 53 39 78 20 61 11 36 18 35 28 37 72 33 60  6  0 64 43 67 12 31  9 54 56 21 83 47 45 62 
 8 58 49 42 27 26 41 55  3 16 51 34 14 74  7 19 82 10 68 66  5 69 29 38 63 48 13 46 79 32 70 17 50  1 23 30  2 24 15 73 81 57 
stderr
Java HotSpot(TM) Client VM warning: No monotonic clock was available - timed services may be adversely affected if the time-of-day clock changes