The easy way to do this is to come up with a number of easier steps to follow, then to code each step, and then put the steps together. Check all the difficult cases (eg: two hundred and six) (eg a hundred and six)
eg
Read words from file into a list of words (std::list<std::string>)
Loop through the list and replace all recognized numbers with "#"
Loop through the list and replace all sequences "#", "and", "#" with "#"
Loop through the list and replace all repeated "#"es with a single "#"
Loop through the list and write to file.