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 rand = new Random();
  13. int r = rand.nextInt(11) + 4;
  14. int [][] array = new int [r][r];
  15. int [] shuf = new int [201];
  16. int last = 201;
  17. for (int i = 0; i < 201; i++)
  18. shuf[i] = i - 100;
  19. for (int i = 0; i < r; i++)
  20. for (int l=0; l< r; l++ ) {
  21. int x = rand.nextInt(last);
  22. array[i][l] = shuf[x];
  23. shuf[x] = shuf[last-1];
  24. last--;
  25. }
  26.  
  27. for (int i = 0; i < r; i++){
  28. for (int l=0; l< r; l++ )
  29. System.out.print(array [i][l] +" ");
  30. System.out.println();
  31. } }
  32. }
Success #stdin #stdout 0.05s 2184192KB
stdin
Standard input is empty
stdout
-56 51 -96 41 -57 79 -6 56 66 
-32 -45 -84 88 -89 -39 93 49 42 
-88 -68 89 -5 -59 -58 48 15 69 
-99 -62 58 -20 46 -77 -97 95 18 
-55 -35 25 29 54 74 26 -1 28 
-19 33 -33 5 53 -11 31 -44 34 
75 24 -63 83 -51 -18 -79 -71 -2 
4 10 77 -42 -23 22 23 -36 60 
13 84 -94 -83 16 68 -25 40 -43