Guest User

Randomizer

a guest
Oct 15th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.Scanner;
  3.  
  4. public class Randomizer {
  5.  
  6.     public static void main(String[] args) {
  7.         Random random = new Random();
  8.         Scanner scan = new Scanner(System.in);
  9.         int n = scan.nextInt();
  10.         int m = scan.nextInt();
  11.         int x = 0;
  12.         if (n > m) {
  13.             for (int i = 0; i < (n - m) + 1; i++) {
  14.                 x = random.nextInt((n - m) + 1) + m;
  15.                 System.out.printf("%d ", x);
  16.             }
  17.         } else {
  18.             for (int i = 0; i < (m - n) + 1; i++) {
  19.                 x = random.nextInt((m - n) + 1) + n;
  20.                 System.out.printf("%d ", x);
  21.             }
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment