ํฐ์คํ ๋ฆฌ ๋ทฐ
package study;
import java.io.*;
class Lotto {
int inwon;
int[] ar = new int[6];
public void input() throws IOException {
BufferedReader in = new BufferedReader ( new InputStreamReader (System.in) );
System.out.print("๋ช๊ฒ์ ํ์ค๋์? ");
inwon = Integer.parseInt(in.readLine());
}
public void numCreate() {
int lottoNum;
int cnt = 0;
while(true) {
int duple = 0;
lottoNum = (int)(Math.random() * 45 + 1);
for (int i = 0; i < ar.length; i++) {
//System.out.print("ar[i] = \t" + ar[i]);
if (ar[i] == lottoNum) { //์ค๋ณต์ฒดํฌ
duple = 1;
}
}
if (duple == 0) {
ar[cnt] = lottoNum;
cnt++;
}
if (cnt == ar.length) break;
}
}
//Sort
public void sort() {
int i, j;
for(i = 0; i < ar.length; i++) {
for(j = 0; j < i; j++) {
if (ar[i] < ar[j]) {
int temp = ar[i];
ar[i] = ar[j];
ar[j] = temp;
}
}
}
}
public void disp() {
System.out.print("์ด๋ฒ์ฃผ ๋น์ฒจ๋ก๋ ๋ฒํธ๋ : ");
for (int i=0; i < ar.length; i++) {
if (i != ar.length -1) {
System.out.print(ar[i] + ", ");
} else {
System.out.print(ar[i]);
}
}
System.out.println();
}
}
public class LottoCreate {
public static void main(String[] ar) throws IOException {
Lotto a = new Lotto();
a.input();
for(int i = 0; i< a.inwon; i++) {
a.numCreate();
a.sort();
a.disp();
}
}
}
'PROGRAMMING' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
์๋ธ๋ฆฟ ํ ํ๋ฆฟ. (0) | 2010.06.08 |
---|---|
์ด๊ฒ์ด ์ค์์ธ๊ฑฐ์ผ? (0) | 2010.05.29 |
Model1 ๋ฐฉ์ (0) | 2010.05.14 |
ํ๋ก๊ทธ๋๋จธ์ ์๊ธฐ์ฌ์ฐ๊ธฐ... (0) | 2009.10.15 |
kakao ์นด์นด์ค๋ท์ปด (2) | 2009.10.09 |
- Total
- Today
- Yesterday
- JavaScript
- ํจ์
- ๊ธฐํ
- ๋์ค
- 2ne1
- ๊ฒฝ์ ์ฉ์ด
- EL
- ์นด๋ฐ์จ๋ผ์ธ
- Java
- php
- asp
- JSON
- ์๋ฐ์คํฌ๋ฆฝํธ
- jQuery
- ๋ฉ๋ฐฐํ
- ์๋ธ๋ฆฟ
- ์ธํจ์ด
- ์๋ฆฌ
- 8๋ง์ผ
- MySQL
- Servlet
- JSP
- I Don't Care
- JS
- ์์์ฌ์ด๋
- Ajax
- ๋ณต๊ทผ์ด๋
- JSTL
- ์น์์ด์ ์
- MS-SQL
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |