It can help to draw a picture. (Personally, I'd draw it with AC horizontal, and BC vertical, but my triangle solver had its own idea.)
Since this is a right triangle, you know B is the complement of A.
... B = 90° - A = 58.7°
You know from the mnemonic SOH CAH TOA that the tangent of an angle is the ratio of the Opposite side to the Adjacent side:
Tan = Opposite/Adjacent
This tells you that
... tan(31.3°) = a/b
... a = b·tan(31.3°) = (42.1 cm)·0.60801
... a ≈ 25.6 cm
The same mnemonic tells you ...
... Cos = Adjacent/Hypotenuse
... cos(31.3°) = b/c
... c = b/cos(31.3°) = (42.1 cm)/0.85446
... c ≈ 49.3 cm