int[] temp = new int[45];
//temp 1~45 숫자 담기
for(int i=0; i< temp.length; i++) {
temp[i] = i+1;
}
// temp 값 섞기
for(int i=0; i<10000; i++) {
int ran = (int)(Math.random()*45);
int t = temp[0];
temp[0] = temp[ran];
temp[ran] = t;
}
// 6자리 로또 값에 temp 값 0~5까지의 값 복사
int[] lotto = new int[6];
System.arraycopy(temp, 0, lotto, 0, 6);
// 숫자 정렬 해보기
for(int i=0; i<lotto.length-1; i++) {
for(int j=0; j<lotto.length-1; j++) {
if(lotto[j]> lotto[j+1]) {
int t = lotto[j];
lotto[j] = lotto[j+1];
lotto[j+1] = t;
}
}
}
// 정렬 후 출력 할 것.
System.out.print("[");
for(int l : lotto) {
System.out.print(l+", ");
}
System.out.println("]");