while (true)
{
Random r = new random ();//Definition of stochastic
ArrayList red = new ArrayList ();//collection type can be put into
while (true)
{
if (red. Count = = 6)//red ball contains six numbers
{
break;//Select six numbers and you will choose to jump out
}
Else
{
int temp = R.next (1, 34);//randomly pick a red ball
if (red. Contains (temp))//Selected red ball and the last red ball repeat
{
}
Else
{
Red. Add (temp);//If repeat is not, add red ball if not repeat
}
}
}
Red. Sort ();
Console.Write ("Red ball for;"); /Output Red ball
for (int i = 0; i < red. Count; i++)//Using loops to select a group of red balls continuously
{
Console.Write (Red[i] + "\ t");
}
Console.Write ("Basketball for" + r.next (1, 17));//basketball only one, so randomly choose one on the line
Console.ReadLine ();
Example: Machine-selected color ball, use the set, sort in the collection, for Loop,. Next random number. A lot of knowledge.