I did not treat this question like a homework question, since it is not tagged homework.
What are the relations between the numerator in [and] the denominator
Both are linear functions of $\sin x,\cos x$
what is the general pattern to solve these type of questions?
The universal standard substitution to evaluate an integral of a rational fraction in $\sin x,\cos x$, i.e. a rational fraction of the form
$$R(\sin x,\cos x)=\frac{P(\sin x,\cos x)}{Q(\sin x,\cos x)},$$
where $P,Q$ are polynomials in $\sin x,\cos x$ is a trigonometric substitution known as the Weierstrass substitution
$$\tan \frac{x}{2}=t,\qquad x=2\arctan t.\tag{*}$$
Differentiating both sides of $(^*)$ w.r.t. $t$, we get
$$\frac{dx}{dt}=\frac{2}{1+t^2},\qquad dx=\frac{2}{1+t^2}dt.$$
Since we know$^1$ from trigonometry that $$\cos x =\frac{1-\tan ^{2}\frac{x }{2}}{1+\tan ^{2}\frac{
x}{2}}=\frac{1-t^2}{1+t^2},\qquad \sin x =\frac{2\tan \frac{x }{2}}{1+\tan ^{2}
\frac{x }{2}}=\frac{2t}{1+t^2},$$
we see that in general, the integrand becomes a rational fraction in $t$, whose standard integration technique is the partial fractions decomposition:
$$\int R(\sin x,\cos x)\, dx=\int R\Big(\frac{2t}{1+t^2},\frac{1-t^2}{1+t^2} \Big)\frac{2}{1+t^2}\, dt.$$
For instance this substitution in the 2nd. integral yields
$$
\begin{eqnarray*}
\int \frac{a\sin x+b\cos x}{c\sin x+d\cos x}dx &=&\int \dfrac{a\dfrac{2t}{
1+t^{2}}+b\dfrac{1-t^{2}}{1+t^{2}}}{c\dfrac{2t}{1+t^{2}}+d\dfrac{1-t^{2}}{
1+t^{2}}}\dfrac{2}{1+t^{2}}dt \\
&=&2\int \frac{bt^{2}-2at-b}{\left( dt^{2}-2ct-d\right) \left(
1+t^{2}\right) }dt.
\end{eqnarray*}
$$
--
$^1$ A possible proof is the following one, which uses the double-angle formulas and the identity $\cos ^{2}\frac{x}{2}+\sin ^{2}\frac{x}{2}=1$:
$$
\begin{eqnarray*}
\cos x &=&\cos ^{2}\frac{x}{2}-\sin ^{2}\frac{x}{2}=\frac{\frac{\cos ^{2}
\frac{x}{2}-\sin ^{2}\frac{x}{2}}{\cos ^{2}\frac{x}{2}}}{\frac{\cos ^{2}
\frac{x}{2}+\sin ^{2}\frac{x}{2}}{\cos ^{2}\frac{x}{2}}}=\frac{1-\tan ^{2}
\frac{x}{2}}{1+\tan ^{2}\frac{x}{2}}, \\
&& \\
\sin x &=&2\sin \frac{x}{2}\cos \frac{x}{2}=\frac{\frac{2\sin \frac{x}{2}
\cos \frac{x}{2}}{\cos ^{2}\frac{x}{2}}}{\frac{\cos ^{2}\frac{x}{2}+\sin ^{2}%
\frac{x}{2}}{\cos ^{2}\frac{x}{2}}}=\frac{2\tan \frac{x}{2}}{1+\tan ^{2}
\frac{x}{2}}.
\end{eqnarray*}
$$