#include <iostream>
#include <string>
using namespace std;
// 有35个头 94只脚 问有多少只鸡和兔
//(总脚数 - 总头数×鸡的脚数)÷(兔的脚数 - 鸡的脚数) = 兔的只数
//(94-35×2)÷2 = 12(兔子数)总头数(35)-兔子数(12) = 鸡数(23)
void calculate(int head, int foot) {
int rabbit, chicken;
rabbit = foot - head * 2;
chicken = head - rabbit;
cout << "兔有" << rabbit << "只,鸡有" << chicken <<"只。" << endl;
}
void main() {
calculate(35,94);
}
02-05
4610
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)