问题:有100匹马,驮100担货,大马驮3担,中马驮2担,两匹小马1担,编程计算所有可能的驮法?
class OperateDemo2
{
public static void main(String[] args)
{
int a,b,c,count=0;
for(a=0; a<100; a++);
{
for(b=0; b<100; b++);
{
for(c=2; c<100; c=c+2);
{
if((a+b+c==100)&(3*a+2*b+c/2==100))
{
count++;
System.out.println(count+"a="+a+" ;b="+b+" ;c="+c);
}
}
}
}
}
}
|
|