设鸡有x只,兔有y只,则x+y = m, 2x+4y = n;
所以y=(n-2m)/2,
x = m-y
代码如下
#include
int main()
{
int m, n;
int chickenNumber = 0;
int rabbitNumber = 0;
scanf("%d%d",&m,&n);
rabbitNumber = (n - 2*m) / 2;
chickenNumber = m - rabbitNumber;
printf("%d %d", chickenNumber, rabbitNumber);
return 0;
}