Example: Machine-selected color ball, use the set, sort in the collection, for Loop,. Next random number. A lot of knowledge.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.