Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1.  
  2. import java.util.Arrays;
  3.  
  4.  
  5.  
  6. public class Lottos {
  7.  
  8. public static int a;
  9.  
  10. public static void main(String[] args) {
  11. int[] lottozahlen = new int[5];
  12.  
  13. for (int i = 0; i < lottozahlen.length; i++) {
  14.  
  15. do {
  16. a = myRandom(1, 49);
  17. lottozahlen[i]= a;
  18. } while (Arrays.binarySearch(lottozahlen, a) == 1);
  19.  
  20. }
  21. System.out.println(Arrays.toString(lottozahlen));
  22. }
  23.  
  24.  
  25.  
  26. public static int myRandom(int low, int high) {
  27. return (int) (Math.random() * (high - low) + low);
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement