c语言编程,这题怎么编

2024-12-31 05:35:46
推荐回答(1个)
回答1:

设鸡有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;
}