/*
?* 一只公鸡5块钱,一只母鸡3块钱,3只小鸡一块钱,
?* 一个农夫用100块钱买100只鸡(不许解方程),怎么实现?
?*/
#include<stdio.h>
/*
?* n1:鸡的总数
?* n2:钱的总数
?*/
void divide(int n1,int n2)
{
??? int i,j;
??? for(i=0;i<n2/5;i++)
?? {
???? ? for(j=0;j<(n2-5*i)/3;j++)
???? {
????? ?? int leave=n1-i-j;
?????? ? if(5*i+3*j+leave/3==n2)
?????? {
???????? ?printf("公鸡=%d,母鸡=%d,小鸡=%d\n",i,j,leave);
?????? }
??? ?}
??}
}
?
int main()
{
???int n1=100;
? ?int n2=100;
?? divide(n1,n2);
?? return 0;
}