百马百担问题:有100匹马,驮100担货,大马驮3担,中马驮2担,两匹小马驮1担,问大,中,小马各有多少?

#include
int main()
{
	int x,y,z;
	for(x=0;x<=33;x++)
	{
		for(y=0;y<=50;y++)
		{
			z=100-x-y;
			if(3*x+2*y+z*1.0/2==100)
			printf("%d,%d,%d\n",x,y,z);
		}
	}
	return 0;
}













#include 
int main()
{
	int a,b,c,sum;
    for (a=0;a<=33;a++)
    {
    	for(b=50;b>=0;b--)
    	{
    		c=100-a-b;
    		if (c%2)//小马是两马驮一货,故小马的数量为双数
			continue;
    		sum=3*a+2*b+c/2;
    		if(sum==100)
			printf("大马%d,中马%d,小马%d\n",a,b,c);
		}
    }
	return 0;
}

你可能感兴趣的:(蓝桥杯,职场和发展)