I get the right results but want to make sure thats how I was supposed to do it
Seems right, though you should consider not using namespace std (if you want to know why, theres a wiki article at `/wiki namespace std`)