View Single Post
Old 03-31-2006, 05:08 PM   #2 (permalink)
ChefFrank
Code Monkey
 
ChefFrank's Avatar
 
Join Date: Mar 2006
Location: Woodbury, CT
Posts: 38
ChefFrank is on a distinguished road
Send a message via Yahoo to ChefFrank
OK - here's how you'd go about doing what you want - I'm not going to do your assignment for you

First, you need to put your text into an array. Find the length of the array.
Second, create a second array of the same size

Your loop is like:

.array1 = "John Smith";
.array2;

For index = 0 to length-1 do {
array2[index] = array1[length - index - 1];
}

So, first time through:

length = 10
index = 0
array1 = "John Smith"
array2 = "h"

Second time through:

length = 10
index = 1
array1 = "John Smith"
array2 = "ht"

The rest is left to the reader as an interesting exercise.

Of course, consider the trivial case:

array1 = "Go hang a salami, I'm a lasagna hog"

Frank
ChefFrank is offline   Reply With Quote