Article View: alt.comp.lang.learn.c-c++
Article #146Re: C++ problem - help
From: Jason Kuchar
Date: Mon, 05 Apr 1999 00:00
Date: Mon, 05 Apr 1999 00:00
38 lines
1853 bytes
1853 bytes
The problem here lies in the last two letters being checked. It looks at the two e's and finishes the loop with Palindrome being true. You could have any word with the same two letters in the middle, and this would still recognize it as a palindrome. One solution is just to assign the Palindrome true when you declare it: char Palindrome = 1; and modify the while loop to look like this: while ((Front < Back) && (Palindrome)) The while loop will then terminate since Palindrome isn't true anymore, - and the rest of the code is still the same - which looks correct to me. Victor wrote: > I have been asked to design a project to determine whether a word is a > palindrome or not (btw a plaindrome is a word that is the same backwards ie > noon). > > I have been able to run the program successfully with some words but it > doesn't seem to like the word 'deer' and other words with the same middle > letters. It thinks that it is a palindrome which is not true. > > Could somebody help please. > > Thanks for your time . . . > >
Technical Details
Message-ID:
<370908E9.D88DB0B3@ugrad.cs.ualberta.ca>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7eatvr$p1g$1@barcode.tesco.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,61f8664269971e91 X-Google-Attributes: gid109fba,public X-Google-Thread: 114592,61f8664269971e91 X-Google-Attributes: gid114592,public X-Google-Thread: 10d4ba,61f8664269971e91 X-Google-Attributes: gid10d4ba,public From: Jason Kuchar <kuchar@ugrad.cs.ualberta.ca> Subject: Re: C++ problem - help Date: 1999/04/05 Message-ID: <370908E9.D88DB0B3@ugrad.cs.ualberta.ca> X-Deja-AN: 462960671 Content-Transfer-Encoding: 7bit References: <7eatvr$p1g$1@barcode.tesco.net> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: University of Alberta Mime-Version: 1.0 Reply-To: kuchar@ugrad.cs.ualberta.ca Newsgroups: alt.comp.lang.learn.c-c++,att.lang.c++,comp.lang.c++