English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

eg :-
then u split it up into : - and
Then u reverse the second half using strreverse
The fold is when u take the second half's characters and place them alternatively with the characters of the first half

like so

2007-05-28 13:04:40 · 1 answers · asked by max 2 in Computers & Internet Programming & Design

1 answers

Take your string and load it into a character array. Determine the upper boundary value of the array . Using two index values one starting at zero and working up and the other starting at the upper boundary and working down assemble a string using these two indexed characters.

The use of a Do loop While will let you take a character from each eand of the array and work toward the middle. A final If/then handles the final character if an odd lenght string was used.

Dim str As String
Dim ch() As Char
Dim cnt, idx As Integer

str = "To be or not to be, that is the question"
ch = str.ToCharArray 'place individual characters into array

cnt = UBound(ch) 'upper limit index value of array
'cnt is downward indexing counter

str = "" 'initialiaze str for reuse in building output string
idx = 0 'initialize upward indexing counter

Do
str = str & ch(idx) & ch(cnt)
idx += 1
cnt -= 1
Loop While idx < cnt 'stop when meeting at middle of string
If idx = cnt Then
str = str & ch(cnt) 'capture remaining character if odd lenght string
End If
Debug.WriteLine(str) 'output results to immediate window

2007-05-28 17:19:12 · answer #1 · answered by MarkG 7 · 1 0

fedest.com, questions and answers