11th weeks-RMB for chicken

Source: Internet
Author: User

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...

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.