기금넷 공식사이트 - 복권 조회 - 자바 (Java) 로 이색구 선택을 보조하는 시스템을 작성하다. 레드볼은 1~33 에서 무작위로 6 개의 번호를 추출하고, 블루볼은 1~ 16 에서 무작위로 1 개 번호를 추출하고, 레드볼 번호를 추출합니다

자바 (Java) 로 이색구 선택을 보조하는 시스템을 작성하다. 레드볼은 1~33 에서 무작위로 6 개의 번호를 추출하고, 블루볼은 1~ 16 에서 무작위로 1 개 번호를 추출하고, 레드볼 번호를 추출합니다

Java.util.arraylist 가져오기

Java.util.list 가져오기

Java.util.random 을 가져옵니다.

/* *

* 무작위 표본 추출 (예: 35 개 중 7 개 등).

*

* @ 작성자 관리자

*

*/

공용 클래스 RandomSelect {

Public static int [] random select (inttotal, int number) {

Int [] result = new int [번호];

목록< 문자열 & gtlist = new ArrayList & lt 문자열> ();

Randomr = new random ();

For(int I = 0;; 나< 합계; I++) {

List.add (I+1+"");

}

For(int j = 0;; J< 번호; J++) {

Intsize = list.size ();

Strings = list.get (r.nextint (size));

Result [j] = integer.parseint (s);

목록. 삭제

}

결과를 반환합니다.

}

공용 정적 void main(String[] args) {

Int[] red = randomSelect(33 (33,6);

Int [] blue = randomselect (16,1);

System.out.println ("빨간 공은:");

For(int I = 0;; 나 & ltred.lengthi++) {

System.out.print (red [I]+"\ t");

}

System. out. println(" \ n 블루 볼은: ");

For(int I = 0;; 나< 블루. 길이 I++) {

System.out.println (블루 [I]+"\ t");

}

}

}