程序代码:
#include<stdio.h>
int main()
{
int x,y,z;
for(x=0;x<=20;x++)
{
for(y=0;y<=33;y++)
{
z=100-x-y;
if(z%3==0 && x*5+y*3+z/3==100){
printf("公鸡:%d,母鸡:%d,小鸡:%d\n",x,y,z);
}
}
}
return 0;
}
运行结果:
标签:枚举法,穷举法,买百鸡,int,main,程序代码
来源: https://blog.csdn.net/qq_41772662/article/details/86481469