Connecting Tech Pros Worldwide Forums | Help | Site Map

an interesting exercise by Accelerated C++

utab
Guest
 
Posts: n/a
#1: Feb 16 '06

Exercise 5.10 from Accelerated C++ by Andrew Koenig

Palindromes are words that are spelled the same right to left as left
to right. Write a program to find all the palindromes in a dictionary.
Next, find the longest palindrome.

How do u think you can supply a dictionary to a program? The examples
are real world problems I have to accept :( but they must be in the
context of a newcomer can cope and learn without discourage. This is my
humble idea.

Any comments...

Thx.


Rolf Magnus
Guest
 
Posts: n/a
#2: Feb 16 '06

re: an interesting exercise by Accelerated C++


utab wrote:
[color=blue]
>
> Exercise 5.10 from Accelerated C++ by Andrew Koenig
>
> Palindromes are words that are spelled the same right to left as left
> to right. Write a program to find all the palindromes in a dictionary.
> Next, find the longest palindrome.
>
> How do u think you can supply a dictionary to a program?[/color]

The easiest would be just a plain simple text file.

Dietmar Kuehl
Guest
 
Posts: n/a
#3: Feb 16 '06

re: an interesting exercise by Accelerated C++


utab wrote:[color=blue]
> Exercise 5.10 from Accelerated C++ by Andrew Koenig[/color]
[color=blue]
> How do u think you can supply a dictionary to a program?[/color]

Since it is very likely that Andrew Koenig had some UNIX exposure
I would guess that he considers the presence of /usr/dict/words
to be a given - as would I (just to learn that it is called
/usr/share/dict/words on the Linux system I'm using...).
[color=blue]
> The examples
> are real world problems I have to accept :( but they must be in the
> context of a newcomer can cope and learn without discourage. This
> is my humble idea.
>
> Any comments...[/color]

I assume your problem is the absence of a dictionary file: just
get one or create one to test with. Reading a file containing
words shouldn't be a problem...
--
<mailto:dietmar_kuehl@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.eai-systems.com> - Efficient Artificial Intelligence
utab
Guest
 
Posts: n/a
#4: Feb 16 '06

re: an interesting exercise by Accelerated C++


Thanks,

I am also using Linux(newbie on that also)

So I can try on that file if I have problems I will drop by again

Closed Thread