C语言求百钱百鸡问题//百钱百鸡问题#include#includeint main(){int cocks;printf("%8s%8s%8s\n","cocks","hens","chicks");for (cocks=0;cocks

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/25 03:25:14
C语言求百钱百鸡问题//百钱百鸡问题#include#includeintmain(){intcocks;printf("%8s%8s%8s\n","cocks","hens","chicks");f

C语言求百钱百鸡问题//百钱百鸡问题#include#includeint main(){int cocks;printf("%8s%8s%8s\n","cocks","hens","chicks");for (cocks=0;cocks
C语言求百钱百鸡问题
//百钱百鸡问题
#include
#include
int main()
{
int cocks;
printf("%8s%8s%8s\n","cocks","hens","chicks");
for (cocks=0;cocks

C语言求百钱百鸡问题//百钱百鸡问题#include#includeint main(){int cocks;printf("%8s%8s%8s\n","cocks","hens","chicks");for (cocks=0;cocks
当然会错阿,如果是3就变成整除了,
整除结果 3/3 = 4/3 = 5/3 = 1;这样当然会出错
不凡看一个结果
11*5+ 6*3+ 83/3 = 55+18+27 = 100
83/3 = 27
建议这样改
if(5*cocks+3*hens+chicks/3.0==100)
>>
if((5*cocks+3*hens+chicks)*3==300)