beautypg.com

HP Integrity NonStop H-Series User Manual

Page 108

background image

lastword = (*pairPtr).first;
cout << endl << lastword << ": " << (*pairPtr).second;
}
cout << endl; // terminate last line
}

An iterator loop is used to cycle over the elements being maintained by the word list. Each new word
generates a new line of output - thereafter line numbers appear separated by spaces. If, for example,
the input was the text:

It was the best of times,

it was the worst of times.

The output, from best to worst, would be:

best: 1

it: 1 2

of: 1 2

the: 1 2

times: 1 2

was: 1 2

worst: 1

This manual is related to the following products: