Update main.cpp

Meat of task.  All but asking user if he/she wants to do it again and freeing the dynamically allocated space has been implemented.