My Computer Programs

(Java) 로또 번호 생성

steloflute 2012. 8. 26. 19:51


import java.util.TreeSet;

public class Lotto {
    public static void main(String[] args) {
        for (int x : lottoNums())
            System.out.print(x + " ");
    }

    public static TreeSet<Integer> lottoNums() {
        TreeSet<Integer> r = new TreeSet<Integer>();
        while (r.size() < 6)
            r.add((int) (Math.random() * 45 + 1));
        return r;
    }
}


'My Computer Programs' 카테고리의 다른 글

(Javascript) 로또 번호 생성  (0) 2012.08.27
(Python) 로또 번호 생성  (0) 2012.08.26
(Windows) Clock  (0) 2012.08.24
(python) triangle  (0) 2012.08.18
(Go lang) web page get, KOSPI200 시세 얻기  (0) 2012.08.12