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)