百鸡问题的求解

/*百鸡问题*/
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int x,y,z;
printf("\n");
for(x=1;x<20;++x)
{
for(y=1;y<33;y++)
{
z=100-x-y;
if((z%3==0)&&((5*x+3*y+z/3)==100))
break;
}
if(x&&y&&z&&y<34)
{
printf("cook=%d hen=%d chicken=%d\n",x,y,z);

}
}
system("PAUSE");
return 0;
}

 

posted @ 2017-04-05 23:18  HGR  阅读(205)  评论(0编辑  收藏  举报