How to solve the problem (1, 2)

Source: Internet
Author: User

I. Currency sharding:

/** Copyright (c) 2014 School of Computer and control engineering, Yantai University * All Rights Reserved. * file name: sum. CPP * Author: Lin haiyun * Completion Date: July 15, November 4, 2014 * version No.: V1.0 ** Problem description: one RMB is exchanged into one cent, two minutes, and five cent coins, how many different exchange methods are there? * Program output: possible output solutions */# include <iostream> using namespace STD; int main () {int I, J, K, Count = 0; cout <"the method for currency sharding is as follows" <Endl; for (I = 0; I <= 100; I ++) for (j = 0; j <= 50; j ++) for (k = 0; k <= 20; k ++) if (I + 2 * j + 5 * k = 100) {count ++; cout <count <":" <I <"," <j <"," <k <Endl;} cout <Endl; return 0 ;}


Running result:

 

 

2. Hundreds of chicken problems:

/** Copyright (c) 2014 School of Computer and control engineering, Yantai University * All Rights Reserved. * file name: sum. CPP * Author: Lin haiyun * Completion Date: July 15, * version No.: V1.0 ** Problem description: poor solution of RMB/Chicken * program output: */# include <iostream> using namespace STD; int main () {Double X, Y, Z, Count = 0; cout <"Weng,, cui has several "<Endl; For (x = 0; x <= 20; X ++) for (y = 0; y <= 33; y ++) for (Z = 0; Z <= 300; Z ++) if (5 * x + 3 * Y + z/3 = 100 & X + Y + z = 100) {count ++; cout <count <": "<x <" "<Y <" "<z <Endl;} cout <Endl; return 0 ;}


Running result:

Conclusion: The if statement cannot use equal signs instead of equal signs (=). Otherwise, an error may occur and it cannot be run.

How to solve the problem (1, 2)

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.