On solving problems in the mechanics of solids and fluids by a generalized method of characteristics