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

For intSub=1 to 4
For intInnerSub=1 to 4
intSubNext = intInnerSub + 1
If (strFirstName(intInnerSub) > str First name(intSubNext) then
strSwap = strFirstName(intInnerSub)
strFirstName(intInnerSub) = strFirstName (intSubNext)
strFirstName(intSubNext) = strSwap
End If
Next intInnerSub
Next intSub

What does this code mean as a whole and what does each line of code perform? I cannot figure this out. By the way strFirstName is an array with five elements.

Thank you so much

2007-03-27 08:35:55 · 2 answers · asked by ostyman09 2 in Computers & Internet Programming & Design

2 answers

it arranges the elements in strFirstName in ascending order (alphabetically, assuming they r strings) in each iteration, it compares each element with the element after it, and swaps them when necessary...

this sort of programs depends on a method called 'bubble sorting'...if u still cant figure it out... i suggest u try this link:
http://en.wikipedia.org/wiki/Bubble_sort

2007-03-27 08:46:31 · answer #1 · answered by Khaled Z 3 · 1 0

it arranges the elements in strFirstName in ascending order (alphabetically, assuming they r strings) in each iteration, it compares each element with the element after it, and swaps them when necessary...

this sort of programs depends on a method called 'bubble sorting'...if u still cant figure it out... i suggest u try this link:
http://en.wikipedia.org/wiki/bubble_sort...

2007-03-27 15:48:13 · answer #2 · answered by No Picture 2 · 0 2

fedest.com, questions and answers