帮我做一个程序

来源:百度知道 编辑:UC知道 时间:2024/05/25 23:08:42
百钱买百鸡问题
公鸡一只五钱,母鸡一只3钱,小鸡三只1钱

公鸡数 x
母鸡数 y
小鸡数 z
for(x=0;x<101;x++)
{ for(y=0;y<(101-x);y++)
{z=100-x-y;
if((z*1/3+y*3+x*5)==100) goto here;
}}
here;
printf(%d/n%/nd%d/n;x,y,z);

#include <stdio.h>
#include <conio.h>
int main(void)
{
int i,j,k,p,a[100],b[100],c[100];
int t=0;
for(i=0;i<=20;i++)
for(j=0;j<=33;j++)
for(k=0;k<=100;k++)
{
if(i*5+j*3+k*1==100)
{
a[t]=i;
b[t]=j;
c[t]=k;
t++;
}
}
for(p=0;p<t;p++)
{
printf("公鸡,母鸡,小鸡的数量分别是:\n");
printf("%d ",a[p]);
printf("%d ",b[p]);
printf("%d\n",c[p]);
}
getch();
return 0;
}

int x,y,z;
for(x=0;x<=100;x++)
{
for(y=0;y<=100-x;y++)
{
z=100-