Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 strings help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Cheburashka




PostPosted: Thu May 07, 2009 6:25 pm   Post subject: strings help

i need to find a way to flip the variable so for example if the person enters a word lets say "myname" i need it to convert to "emanym", so i can work with it later.
if anyone knows a possible code to do that please help

or

you know how you can get to display variables letters such as name(1..3)
how is it possible to make it (3..1)??????????
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu May 07, 2009 6:54 pm   Post subject: RE:strings help

well you can start with name(1), name(2), name(3), and then place them in the correct order.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Cheburashka




PostPosted: Thu May 07, 2009 7:00 pm   Post subject: Re: strings help

i get what you mean i tried it before, but my teacher said there is a way to simplify it, so i think its either reverse the name and mak i go (1..3),, or somehow chafigure out the (3..1) way
andrew.




PostPosted: Thu May 07, 2009 7:10 pm   Post subject: RE:strings help

Try using for loops to go through each letter forwards and then backwards with another for loop.
Dusk Eagle




PostPosted: Thu May 07, 2009 7:38 pm   Post subject: Re: strings help

I don't see why you need to go forward through the loop at all. Do you know how to go backward through a for loop? If so this task should be pretty simple. (If you don't, look in the Turing documentation of 'for' loops).
Cheburashka




PostPosted: Thu May 07, 2009 7:44 pm   Post subject: Re: strings help

Dusk Eagle @ Thu May 07, 2009 7:38 pm wrote:
I don't see why you need to go forward through the loop at all. Do you know how to go backward through a for loop? If so this task should be pretty simple. (If you don't, look in the Turing documentation of 'for' loops).


yeah its
for decreasing

what i've tried is

for decreasing x : len .. 1
put name (x)

end for

it works but its in the upward direction like

a
m
a
n

when i press locate it only gives me the first letter of the name

if possible can you please tell me what i need to fix about it
Cheburashka




PostPosted: Thu May 07, 2009 7:47 pm   Post subject: Re: strings help

Dusk Eagle @ Thu May 07, 2009 7:38 pm wrote:
I don't see why you need to go forward through the loop at all. Do you know how to go backward through a for loop? If so this task should be pretty simple. (If you don't, look in the Turing documentation of 'for' loops).


actally nvm i think i already got it
thanks for help though
Kharybdis




PostPosted: Thu May 07, 2009 7:55 pm   Post subject: Re: strings help

Cheburashka @ Thu May 07, 2009 7:44 pm wrote:
Dusk Eagle @ Thu May 07, 2009 7:38 pm wrote:
I don't see why you need to go forward through the loop at all. Do you know how to go backward through a for loop? If so this task should be pretty simple. (If you don't, look in the Turing documentation of 'for' loops).


yeah its
for decreasing

what i've tried is

for decreasing x : len .. 1
put name (x)

end for

it works but its in the upward direction like

a
m
a
n

when i press locate it only gives me the first letter of the name

if possible can you please tell me what i need to fix about it


Turing:

var sentence := "This is a sentence!"
for decreasing i : length(sentence) .. 1
put sentence(i) ..
end for
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: