So, for both of those cases, if one of the powers is odd, you take out one of the functions and put it at the end, so in odd cosine, you'd put the cosine at the end. In odd sine, you'd put the sine at the end.

Both Even

That sucks. You have to power reduce, meaning you turn $\sin^2{x}$ into $\frac{1 - \cos{(2x)}}{2}$ and $\cos^2{(x)}$ into $\frac{1 + \cos{2x}}{2}$.

(note that the first part was done using a u-sub)
The recursive part of the solution is you have to keep doing that until you reduce the power of the tan to ∫tan2(x)dx (just convert to sec) or ∫tan(x)dx (u-sub).