Home > Back-end >  C language chicken with rabbit cage
C language chicken with rabbit cage

Time:04-26

This is a relatively simple math problem: the number of chickens and rabbits is unknown, according to the known conditions listed two equations, to work out the number of chickens and rabbits,

 # include & lt; Stdio. H> 
//chicken with rabbit cage,
Int main (void)
{
Int a1, b1, c1, a2, b2, c2.
Int x, y;//the number of chicken rabbit
Printf (" input the first equation of a1, b1, c1: ");
The scanf (" % d % d % d ", & amp; A1, & amp; B1, & amp; C1);
Printf (" \ n input the second equation of a2, b2, c2: ");
The scanf (" % d % d % d ", & amp; A2, & amp; B2, & amp; C2);
If b1 b2 - a2 (a1 * *==0)//no judgment formula
{
Printf (" \ nerror do inpit again. \ n ");
}
X=(b2 - c2 c1 * * b1/b2 - a2 (a1 * * b1);//the number of chickens
Y=c2 - a2 (a1 * * c1)/b2 - a2 (a1 * * b1);//the number of rabbit
Rabbits chickenes printf (" % d, % d ", x, y);
return 0;
}


The results
  • Related