问题及代码:
/ *
*Copyright (c) 2014,烟台大学计算机学院
*All rights reserved .
*文件名称:test .cpp
*作 者:曹莉萍
*完成日期:2014 年11月4日
*版 本 号:v1.0
*
*问题描述:一百钱买一百只鸡,共计三种类型。
*输入描述:无
*程序输出:不同的购买方案
* /
#include <iostream>
using namespace std;
int main()
{
int x,y,z,count=0;
cout<<"百钱买鸡的方案有:";
for (x=1;x<=20;x++)
for (y=1;y<=33;y++)
for (z=1;z<=300;z++)
if (5*x+3*y+z/3==100&&x+y+z==100)
{
++count;
cout<<count<<":"<<x<<","<<y<<","<<z<<endl;
}
return 0;
}
运行结果