Factoring Polynomials in C++

I am attempting to write a program that factors polynomials, but I am in a bit of a jam on how to do it. So far I have developed some steps, but those are just for binomials, anyways, here is what I have so far.

------------------------------------------------------

Step 1: Check for common monomial factors

Step 2:Check for Difference of Squares

Step 3: Check for 3 terms

Step 4: Check for Perfect Binomial Square

------------------------------------------------------

Thank you very much.