百度的盈利模式有哪些:帮我做一个程序

来源:百度文库 编辑:中科新闻网 时间:2024/05/10 08:31:02
百钱买百鸡问题
公鸡一只五钱,母鸡一只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-x-y;
if(z%3 == 0 && 5*x+3*y+z/3 == 100)
{
Console.WriteLine("公鸡:{0}",x);
Console.WriteLine("母鸡:{0}",y);
Console.WriteLine("小鸡:{0}",z);
}
}
}

公鸡:0
母鸡:25
小鸡:75