C#, 윈도우 폼을 이용하여,
(아주 딥하게 말씀드리면, label하나, 텍스트 박스 여섯개, 버튼 한개)초 간단하게, 로또 번호 추출기를 만들어 보고자......
일단 소스만 올립니다.
using System;
using System.Windows.Forms;
namespace WinFrmLotto
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int[] lot = new int[6]; //결과값을 담을 배열
int digit = 0;
Random rnd = new Random();
private bool Numbers(int Num)
{
bool selection = false;
for (int i = 0; i < lot.Length; i++)
{
if (lot[i] == Num)
{
selection = true;
break;
}
}
return selection;
}
private void button1_Click(object sender, EventArgs e)
{
int i = 0;
while (i != 6)
{
digit = rnd.Next(1, 46);
if (!Numbers(digit))
{
lot[i] = digit;
i++;
}
}
Array.Sort(lot);
textBox1.Text = lot[0].ToString();
textBox2.Text = lot[1].ToString();
textBox3.Text = lot[2].ToString();
textBox4.Text = lot[3].ToString();
textBox5.Text = lot[4].ToString();
textBox6.Text = lot[5].ToString();
}
}
}
저기 textBox?.Text 다음줄로 각각. Thread.Sleep(500); 정도 를 넣어주심 더 재미있는 효과가 나타날지도 ㅎㅎㅎ

