Objective: To try the best practices
Content on the machine: Use the for statement and if statement to solve the actual problem
Program:
/** Copyright (c) 2012, School of Computer Science, Yantai University * All Rights Reserved. * Author: Qiu xuewei * Completion Date: July 15, November 8, 2012 * version: V1.0 ** input Description: none * Problem description: experience exhaustion and use it to solve practical problems. * Program output: the type of the chicken that can be purchased for a hundred dollars */# include <iostream> using namespace STD; int main () {int x, y, z; // define the data type as an integer to prevent the occurrence of for (x = 1; x <= 20; ++ X) for (y = 1; Y <= 33; ++ y) // running .... For (Z = 1; Z <= 300; ++ Z) if (5 * x + 3 * Y + 1/3 * z = 100 & X + Y + z = 100) {cout <"Chicken Weng" <x <"only, chicken mother" <Y <"only, chicken chicks" <z <"only. "<Endl;} return 0 ;}
Running result:
Experience: In the past, we could only solve this type of mathematical problem by using equations. After learning C ++, You can compile a program to solve the problem, just a little mouse, and it is not difficult...