'난수'란 ? 임의의 수.

Math.random() : 0<=난수<1 사이의 난수를 발생. (실수)

Math.random() * 100; 0<=수<100 // 

int n;

int cnt;

 

cnt=0;

while(cnt<100) {

cnt=0;

n = (int)(Math.random() * 100) + 1;  // +1을해야 1부터 100까지임.

 

if(cnt%10==0){

System.out.println();

}

}

출력은 한 줄에 10개씩.

+ Recent posts