Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.43 KB | None | 0 0
  1.     // Generate numVals random integers in the range 0 - maxVal, inclusive.
  2.     // Record in the count array at index k the number of times that k occurs
  3.     // as one of the random integers.
  4.    
  5.     private static void genCounts(int numVals, int[] count) {
  6.         int idx;
  7.         for(int k = 0; k < numVals; k++) {
  8.             //count[k] = (int)(Math.random() * (maxVal + 1));
  9.             idx = (int)(Math.random() * (maxVal + 1));
  10.             count[idx]++;
  11.         }
  12.  
  13.    
  14.     } // genCounts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement