百钱买百鸡的问题
公元钱五世纪,我国古代数学家张丘建在《算经》一书中提出了“百鸡问题”:鸡翁一值钱五,鸡母一值钱三,鸡雏三值钱一。百钱买百鸡,问鸡翁、鸡母、鸡雏各几何?main( )
{
int cocks,hens,chicks;
cocks=0;
while(cocks<=19)
{
hens=0;
while(hens<=33)
{
chicks=100-cocks-hens;< BR> if(5*cocks+3*hens+chicks/3==100&&chicks%3==0)
printf("%d,%d,%d\n",cocks,hens,chicks);
hens=hens+1;
}
cocks=cocks+1;
}
}这是源程序,可我自己用for改了以后编译没问题,可却没结果,请各位大神看看我哪边错了
#include "stdio.h"
void main()
{int cocks , hens, chicks;
for (cocks=0;cocks<=19;cocks=cocks+1)
{for(hens=0;hens<=33;hens=hens+1)
{chicks=100-cocks-hens;
if(5*chicks+3*cocks+hens/3==100&&chicks%3==0)
printf("%d,%d,%d\n",cocks,hens,chicks);
}
}
}