Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. public static void main(String[] args) {
  2. SecureRandom sr = new SecureRandom();
  3. Scanner input = new Scanner(System.in);
  4.  
  5. System.out.print("Enter the numbers of columns: ");
  6. int i = input.nextInt();
  7.  
  8. System.out.print("\nEnter the number of rows");
  9. int j = input.nextInt();
  10.  
  11. int[][]a = new int[i][j];
  12.  
  13. System.out.print("\nEnter the number of random numbers in this array: ");
  14. int n = input.nextInt();
  15.  
  16. for(int x = 0; x < a.length; x++)
  17.  
  18. for(int y = 0; y < a.length; x++)
  19. a [x][y] = a[sr.nextInt(n)][sr.nextInt(n)];
  20.  
  21.  
  22. readArray(a);
  23. }
  24. public static void readArray(int[][]x){
  25.  
  26. for(int i = 0; i < x.length; i++)
  27. for(int j = 0; j < x.length; j++)
  28. System.out.println(" "+x[i][j]);
  29.  
  30.  
  31.  
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement