穷举算法
笼子里关着若干只鸡和兔,共有35个头,94只脚。问笼中鸡兔各多少?
int Exhaustive(int headNum,int feetNum,int chichen,int rabbit)
{
int IsFind=0,i=0,j=0;
for(i=0;i<=headNum;i++)
{
j = headNum - i;
if(foodNum == (i*2 + j*4))
{
IsFind = 1;
*chicken = j;
*rabbit = i;
}
}
return IsFind;
}