Computer Science Canada reversing words |
Author: | baby_bubblz [ Tue Nov 23, 2004 8:43 pm ] |
Post subject: | reversing words |
hey can someone help me fill in the ??????? with reversing a word the user inputs? it'd be really helpful. thanks! i think part of it goes something like this: var word: string var reverse: string put "enter a word" get word for decreasing i: length(word) .. 1 ???????????????? and i think there's something like word(length(word))? end for "the reversed word is " , put reverse |
Author: | Cervantes [ Tue Nov 23, 2004 9:00 pm ] | ||||
Post subject: | |||||
Right-o! Determining that you need to use a for loop and the length() function was the hard part! So, if you want to simply output the reversed word on the screen, try this:
If you actually want to save it to a variable, try this:
I hope that helped. |
Author: | wtd [ Tue Nov 23, 2004 9:18 pm ] | ||
Post subject: | |||
Also, consider the recursive solution:
|
Author: | zylum [ Tue Nov 23, 2004 11:29 pm ] | ||
Post subject: | |||
or simply :
![]() |
Author: | con.focus [ Sun Nov 28, 2004 7:52 pm ] | ||
Post subject: | |||
i think this is wut u were originally going for |