"Victor Bazarov" writes:
> osmium wrote:
>> "arnuld" writes:
>>
>>> /* C++ Primer 4/e
>>>
>>> * exercise 6.12, page 208
>>> * STATEMENT
>>> * write small programme to read a sequence of strings from
>>> standard input
>>> * looking for duplicated words. the programme should find places in
>>> the input where
>>> * one word is followed immediately by itself. keep track of the
>>> largest number of
>>> * times a single repetition occurs and which word is repeated . print
>>> the maximum
>>> * number of duplicates or else print the message that no word was
>>> repeated. e.g for
>>> * the input of:
>>> * how cow now now how cow cow now now now how how
>>> * the output should say: "now" occurs 3 times
>>> *
>>> */
>>>
>>> #include<iostream>
>>> #include<string>
>>
>> Does not have
>>
>> #include <map>
>>
>> Which is, IMO, the proper way to solve the problem described in the
>> header.
>
> The propriety of the way depends on the knowledge the book assumes
> accumulated by the time the exercise is presented. If 'std::map'
> has not been discussed before chapter 6, it cannot be used, AIUI.
That's a good point which I didn't consider. BTW, I don't even know what
book is being discussed, I think there are at least two books with that
title. But my general feeling is that you shouldn't give a problem that
can't be solved "properly". I can see isolated instances where this rule is
not followed, but I think such cases should be few and far between.