[C++]百钱买百鸡
2015-11-14 17:32
274 查看
/*<p>1. (百钱买百鸡)雄鸡7元1只,母鸡5元1只,小鸡1元3只。花100元钱,买100只鸡,如果雄鸡、母鸡和小鸡都必须有,则雄鸡、母鸡和小鸡各买几只?</p>*/
#include<iostream> #include<string> using namespace std; void main() { int gj, mj, xj; for (gj = 1; gj < 15; gj++) { for (mj = 1; mj <= 20; mj++) { for ( xj = 3; xj <=100; xj+=3) { if ((gj+mj+xj==100)&&(7*gj+5*mj+1/3*xj)) { cout << gj << ' ' << mj << ' ' << xj << endl; return; } } } } cout << "no answer" << endl; }
相关文章推荐
- C++源文件名与函数名
- LeetCode----Insertion Sort List
- c++中string类的详解
- C++之string学习笔记(1)
- c++堆和栈(2)
- struct和typedef struct彻底明白了
- 用C语言编写函数,实现strlen计算字符串长度的功能
- C语言的那些秘密之---函数返回局部变量
- c++primer文本查询系统
- 我准备的C++面试题
- c语言:常用各种头文件的作用,如:#include <stdlib.h>
- C++基本知识(二)——vector与迭代器和数组与指针
- C++STL之迭代器
- 从零开始学C++之STL(一):STL六大组件简介
- C++标准模板库 迭代器 iterator 详解(二)
- C++标准模板库 迭代器 iterator 详解(一)
- 浅析OC语言
- VC++中从txt文本中读取数据并且存到二维数组中
- C++迭代器 iterator (二)
- C++迭代器 iterator (一)