36. Hundreds of horse problems. There are 100 horses, 100 horses, 3 horses, 2 horses, and 1 horse, and how many groups of solutions are there?

Source: Internet
Author: User
// 1. First, determine the variable relationship, divide the problem into three dimensions, use the for statement nesting to build a loop framework // 2. Use the judgment Statement on the inner layer to determine the conditions that meet the problem // note that, set a variable for counting? # Include <iostream> using namespace STD; int main () {int m = 0; For (INT I = 1; I <= 100; I ++) {for (Int J = 1; j <= 100; j ++) {for (int K = 1; k <= 100; k ++) {If (I + J + k) = 100) & (3 * I + 2 * j + 0.5 * K) = 100 )) {cout <"Trojan:" <I <"Trojan:" <j <"Pony:" <K; m ++; cout <Endl ;}}}cout <"Total" <m <"group solution" <Endl; return 0 ;}

A similar problem occurs: How many exchange methods can I change my money into a coin (1 minute, 2 minutes, 5 minutes?

# Include <iostream> using namespace STD; int main () {int y = 100; int m = 0; For (INT I = 1; I <= y; I ++) {for (Int J = 1; j <= y; j ++) {for (int K = 1; k <= y; k ++) {if (I + 2 * j + 5 * k = y) {cout <"one cent:" <I <"two cent: "<j <" 5 cent: "<K; m ++; cout <Endl ;}}}} cout <"Total" <m <"exchange mode" <Endl; return 0 ;}

 

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.