Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
673 B
3
Indexable
Never
import java.util.Random;

public class Main {
    public static void main(String[] args) {

        Random r = new Random();
        int num;

        int[] numerot;
        numerot = new int[7];

        for (int i = 0; i < numerot.length; i++) {

            do {
                num = r.nextInt(34) + 1;

                for(int j = 0 ; j < numerot.length ; j++) {

                    if(num == numerot[j]) {
                        num = -1;
                        break;
                    }

                }

            } while(num == -1);
            numerot[i] = num;
            System.out.println(numerot[i]);
        }
    }
}
Leave a Comment