Algorithm overview-2-bubble sort method: buy a chicken for a hundred dollars Algorithm

Source: Internet
Author: User

Reading directory

I. Instances

Ii. Running Effect

I. Instances

Private void btnJiSuan_Click (object sender, EventArgs e) {int a = 0, B = 0, c = 0, d = 0; // define the variable // The rooster's traversal in the hundred yuan for (a = 1; a <= 19; a ++) {// the hen's traversal in the hundred yuan for (B = 1; B <= 33; B ++) {c = 100-a-B; // obtain the total amount of money Math from the chicks except the rooster and hen. divRem (c, 3, out d); // calculate the number of chicks // If the rooster, hen, and the total amount of chicken money is 100 if (5 * a + 3 * B + c/3) = 100) {this. textBox1.Text =. toString (); this. textBox2.Text = B. toString (); this. textBox3.Text = c. toString ();}}}}

 

Ii. Running Effect

 

 

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.