By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,695 Members | 1,580 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,695 IT Pros & Developers. It's quick & easy.

How to find those word which give the same spelling from both site

P: 43
I want to to find those word in array list which give the same spelling when we
spell out it from Right and left site.

For example.

like this word (Ababa)
if we spell out this word form Right and left site it give the same spelling

how should i do give me the best answer.
Apr 4 '10 #1
Share this Question
Share on Google+
8 Replies


tlhintoq
Expert 2.5K+
P: 3,525
Loop through it one letter at a time
If start of string equals end of string
If start of string + 1 equals end of string -1
If start of string + 2 equals end of string -2
and so on
Apr 4 '10 #2

tlhintoq
Expert 2.5K+
P: 3,525
please send the complete example,i did not understand.
Can anybody send me code to [...]
The Bytes volunteers are not here to write your code for you. This is not a free homework service.
Bytes is very much a "Give me a fish I eat for a day. Teach me to fish I eat for a lifetime" kind of place. Just giving you the code doesn't help you learn near as effectively as good old-fashioned trial and error.

Do a little reading up and experimenting then if your trials aren't doing what you expect, post the code and relevant messages/errors and we'll see what we can do to point you in the right direction for making it work.

Try hitting Google with terms of your programming language and primary terms of what you want to do. For example "C# custom events" or "VB datagrid Excel". I've found this to be a very effective tool.

May I suggest
  • First: Do some research. I heard about thing thing called Google, or books even.
  • Second: Do some experiments yourself. You will learn so much from actually trying it before throwing up your hands in defeat before even starting.
  • Third: Show the volunteers here the code that you created that was the closest to successful along with relevant errors.

Bytes has a policy regarding assisting students with their homework.

The short version is that the volunteers here can't help you with schoolwork.
A) We don't know what material you have and have not learned in class.
B) We don't know the guidelines you must follow.
C) In the long run giving you the answers actually short changes your education.

Hint 1: Try hitting Google with terms of your programming language and primary terms of what you want to do. For example "C# custom events" or "VB datagrid Excel". I've found this to be a very effective tool.
Hint 2: Your text book
Hint 3: Your instructor
Hint 4: Posting guidelines regarding homework assignments.
Apr 4 '10 #3

P: 43
thats right,
But i try my best so many time, but with getting no souch resutl.
Apr 5 '10 #4

tlhintoq
Expert 2.5K+
P: 3,525
I'm glad to read that you have been trying. Post your most successful code and maybe we can help point out your mistake, without completely violating our policy about helping with student homework.
Apr 5 '10 #5

P: 43
Expand|Select|Wrap|Line Numbers
  1. Sub Main()
  2.         Dim array As String() = New String(0) {}
  3.         Console.Write("Enter Any Word: ")
  4.         For i As Integer = 0 To array.GetUpperBound(0)
  5.             'Console.Write("The output is {0}", array(i))
  6.             array(i) = Console.ReadLine()
  7.             Console.Write("{0}", array(i))
  8.  
  9.         Next
  10.         Console.ReadLine()
  11.     End Sub
-----------------------------------
this is the code, now i want to apply Condition that if the word is = give the same spelling from both right and left site then do this and ETC.
Apr 5 '10 #6

tlhintoq
Expert 2.5K+
P: 3,525
Where is your effort to see if the word is the same back-to-front as front-to-back?

You said you had tried many different ways but none worked. Show me a couple examples of what you tried/coded.
Apr 5 '10 #7

P: 43
i want ot find those word which give the same spelling from both right and left site

this is the effort that i do
---------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. Dim array1 As Char() = New Char(0) {}
  2.         For i As Integer = 0 To array1.GetUpperBound(0)
  3.             Console.Write("Enter Any Name [{0}]: ", i + 1)
  4.             array1(i) = Console.ReadLine()
  5.             If (array1.GetLowerBound(0)) = array1.GetUpperBound(0) _
  6.                 And (array1.GetLowerBound(0) + 1) = (array1.GetUpperBound(0) - 1) _
  7.                 And (array1.GetLowerBound(0) + 2) = (array1.GetUpperBound(0) - 2) _
  8.                 And (array1.GetLowerBound(0) + 3) = (array1.GetUpperBound(0) - 3) _
  9.                 And (array1.GetLowerBound(0) + 4) = (array1.GetUpperBound(0) - 4) Then
  10.                 Console.Write("The spelling is the same form both left and right site")
  11.             Else
  12.                 Console.Write("The spelling is not the same form both left and right site")
  13.             End If
  14.         Next
  15.         Console.ReadLine()
-------------------------------------------
it give the same message for both (IF and Else)condition =(the spelling is not the same from both right and left site.

please help me.looking forword
Apr 6 '10 #8

Frinavale
Expert Mod 5K+
P: 9,731
Find the mid point in your String.
To do this, use the String.Length property and divide it by 2 to get to the middle.

Now you can implement recursive method to do this or you can use a loop..but essentially you want to check the last element in the string and compare it to the first element in the string....if they match you want to compare the second last element in the array to the second element in the array...if they match then compare the ....

You get the point.

Your logic should look like (pseudo code):
Expand|Select|Wrap|Line Numbers
  1. midPoint = myString.Length/2
  2.  
  3. If(midpoint>0)
  4.   counterDown = myString.Length
  5.   counterUp = 0
  6.   for counterUp to midPoint increment counterUp by 1
  7.     if myString.SubString(counterUp) 
  8.     is not equal to myString.SubString(counterDown) 
  9.         exit the loop because they don't match.
  10.    end if
  11.   loop
  12.  
-Frinny
Apr 13 '10 #9

Post your reply

Sign in to post your reply or Sign up for a free account.