|
Post by rishabhchandak on Mar 12, 2007 6:31:34 GMT
i am in class 7...how to check wether a string is a palindrome or not??...plz help quickly....dont use anything except right left and mid$
|
|
|
Post by Mikrondel on Mar 13, 2007 9:01:27 GMT
Though it'd be really nice if you showed us what you've already tried, I'll give you some pointers:
Palindromes are the same backwards and forwards. (Sometimes you must ignore spaces but that makes the problem harder - if you weren't told to do so then don't do it)
Now, you actually can't solve this problem with just LEFT$, RIGHT$ and MID$ - you also need a loop of some sort and at least one IF-THEN to indicate whether or not the string is a palindrome.
Approaches - there are a few of them. One is to check all "mirror pairs", that is, check the first and last letters are identical, then the 2nd and 2nd last letters, and so on up to the middle. Another is simply to reverse the order of the string, and see if it is the same as the original.
See what you can come up with. If you're still stuck, please show us the code you have written so we can help you improve it. Good luck!
|
|