class 로또번호만들기 { public static void main(String[] args) { int[] lotto = new int[6]; for(int i=0; i< lotto.length; i++) { int num = (int)(Math.random() *45 +1); lotto[i] = num; }// 배열에...
//로또 프로그램 =================================== for(int i=0; i<6; i++) { lotto[i] = (int) (Math.random()*45+1); for(int j=0; j<i; j++) { while(lotto[i] == lotto[j]) { lotto[i] = (int)...
++i) { com[i]=(int)(Math.random()*45)+1; for(int j=0; j<i; ++j) { if(com[i]==com[j]) { --i; break; } } } int [] you=new int[6]; for(int i=0; i<you.length; ++i) { do { System.out.print(i+1+"번째 수를...
오늘은 Math.random()이라는 자바안에 있는 함수를 알아볼까 합니다. 이 랜덤함수는 굉장히... 하나는 로또와 같은 게임을 우리가 만들려고 할때 등 정말 많은 부분에서 이 함수를 사용 할 수 가...
-
// 1 <= x <= 10 // 로또 번호 1개 생성( 1 ~ 45 사이의 난수) System.out.println((int)(Math.random() * 45) + 1); 2. Random클래스 java.util.Random 클래스 - 난수 발생 전용 클래스 - Math...
... public class LottoEx extends JFrame{ public LottoEx() { setTitle("로또 번호 추첨");//컨탠트팬... print((int)(Math.random()*45+1)+", "); Component c=(Component)e.getSource(); } System.out.println("Left Button...
... System.out.println("***로또 번호 자동 생성***"); // int[] new_num = new int[6]; int[] lotto =new int[6]; for(int i=0;i<6;i++) { lotto[i] = (int)(Math.random()*45); //중복제거--정렬(비슷) for(int j=0;j<i;j++) { if(lotto[i]==lotto...
... j++) { System.out.print(로또한장[j] + " "); } System.out.println(); } } public static int 랜덤숫자생성() { // 1 ~ 45 사이의 랜덤 숫자를 생성 double rand = Math.random(); return (int) (rand * 45) + 1; } }
... while(count!=6) { int temp=(int)(Math.random()*45)+1; int flag =0; for(int i=0; i<6; i++) { if(lots[i]==temp) { flag=1; break; } } if(flag==0) { lots[count++]=temp; } } } public static void main(String[] args) { // TODO Auto...
Math.random()*100%45 랜덤 소숫점에 값을 곱해서 숫자를 출력하는건 알겠는데, 저 100%45가 계산이 어떻게되서 1~45숫자를 출력하게되는지 잘 이해가안됩니다. ㅜ random() 이라는 함수는 0 이상 1미만의 숫자 중에서 아무...