第三周项目4—穷举法解决组合问题

来源:互联网 发布:pcb画图软件 编辑:程序博客网 时间:2024/05/16 06:11
#include<iostream>using namespace std;int main(){    int x,y,z;//x为公鸡 5钱,y为母鸡 3钱,z为鸡雏 1钱(3只)    for(x=0; x<=20; x++)        for(y=0; y<=33; y++)        {            z=(100-5*x-3*y)*3;            if(x+y+z==100)                cout<<"gongji:"<<x<<" "<<"muji:"<<y<<" "<<"jichu:"<<z<<endl;        }    return 0;}


}
0 0
原创粉丝点击