百钱百鸡问题

来源:互联网 发布:数据权限字段 java 编辑:程序博客网 时间:2024/05/23 19:19

中国古代数学家张丘建在他的《算经》中提出了著名的“百钱买百鸡问题”:鸡翁一,值钱五,鸡母一,值钱三,鸡雏三,值钱一,百钱买百鸡,问翁、母、雏各几何?

#include<iostream>#include<iomanip>using namespace std;int main(){    int a,b;    int i=0;    cout<<"鸡鸡数量:"<<endl;    for(int x=1;x<=12;x++)      for(int y=1;y<=20;y++)        for(int z=1;z<=84;z++)    {        a=x+y+z;        b=5*x+3*y+z/3;        if((100==a)&&(100==b)&&0==z%3)            cout<<x<<" "<<y<<" "<<z<<endl;        //else {cout<<"无解"<<endl;cout<<++i<<endl;}    }    return 0;}

C++不是算这个的,matlab才是。。。

0 0