Pete1

Untitled

Mar 17th, 2016
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1.  
  2. import java.util.ArrayList;
  3. import java.util.Collections;
  4. import java.util.List;
  5. import java.util.Scanner;
  6.  
  7. public class Problem7RandomizeNumbersFromNToM {
  8. public static void main(String[] args) {
  9. Scanner console = new Scanner(System.in);
  10. int n = console.nextInt();
  11. int m = console.nextInt();
  12. int biggerNumber = 0;
  13. int smallerNumber = 0;
  14.  
  15. if (n > m) {
  16. biggerNumber = n;
  17. smallerNumber = m;
  18. } else if (n < m) {
  19. biggerNumber = m;
  20. smallerNumber = n;
  21. } else {
  22. System.out.println(n);
  23. }
  24.  
  25. List<Integer> numbers = new ArrayList<>();
  26.  
  27. for (int i = smallerNumber; i <= biggerNumber; i++) {
  28. numbers.add(i);
  29. Collections.shuffle(numbers);
  30. }
  31. for (int item : numbers) {
  32. System.out.println(item);
  33. }
  34.  
  35.  
  36. }
  37. }
Add Comment
Please, Sign In to add comment