For generating random numbers you can use the
rand function. It should initialized before the first call with srand. Maybe you also look at this
C++ tutorial when you need further basic knowledge.d
Brute force is mostly not best solution, so you should inform about the theory.
Good luck with your homework. It has the purpose that
YOU learn more about that stuff.