Let $Y$ be the rest of the leg on which $A$ lies. Then $$\begin{align} \frac{C^2}{Y^2} = \frac{B^2}{B^2 + (A+Y)^2} &\iff B^2Y^2 = C^2(B^2 + A^2 + 2AY + Y^2)\\\ &\iff (B^2 - C^2)Y^2 - 2AC^2Y - C^2(A^2 + B^2) = 0.\end{align}$$
Using the quadratic formula,
$$\begin{align} Y & = \dfrac{2AC^2 \pm \sqrt{4A^2C^4 + 4(B^2-C^2)C^2(A^2+B^2)}}{2(B^2-C^2)} \\\ & = \dfrac{AC^2 \pm \sqrt{A^2C^4 + A^2B^2C^2 + B^4C^2 - A^2C^4 - B^2C^4}}{B^2-C^2} \\\ &= \dfrac{AC^2 \pm C \sqrt{A^2B^2 + B^4 - B^2C^2}}{B^2-C^2} \\\ &= \dfrac{AC^2 \pm BC \sqrt{A^2 + B^2 - C^2}}{B^2-C^2}. \end{align}$$ We know $B>C$ since $C$'s triangle is similar to the overall triangle and embedded in it, so the radical is always real. Also $BC \sqrt{A^2 + B^2 - C^2} > ABC > AC^2$, and $Y$ is positive, so the plus case gives us the only solution:
$$Y = \dfrac{AC^2 + BC \sqrt{A^2 + B^2 - C^2}}{B^2-C^2}.$$
Then $\dfrac{Y}{A+Y} = \dfrac{X}{B}$, so $X = \dfrac{BY}{A+Y}$.