2012年3月23日金曜日

java で 1~n の整数で毎回異なる乱数

すぐに忘れるので。
private int random(int n)
{
    return ((int) (Math.random() * n + 1));
}

0 件のコメント:

コメントを投稿