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

Username:   Password: 
 RegisterRegister   
 Switching around the sequence of numbers in an array.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
SYZekrom




PostPosted: Mon Dec 14, 2015 11:11 pm   Post subject: Switching around the sequence of numbers in an array.

What is it you are trying to achieve?
I have an array of 10 numbers. I have to switch the numbers by pairs, so if my array had
32 87 1 36 36 23 457 23 64 447
after switching, I would have
87 32 36 1 23 36 23 457 447 64

What is the problem you are having?
While I know in theory how I might be able to do this, I have no idea how to actually write it out in turing code


Describe what you have tried to solve this problem
So, I'm guessing this is what I have to do: store the first number in tthee array somewhere else, let's say an var int named temp, replace the first number with the second number, then replace the second number with what's stored in temp, then repeat with the third and fourth, the fifth and sixth, etc. I'm assuming I'll have to do that with a mod to get every even/odd number.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


<Add your code here>



Please specify what version of Turing you are using
4.0 or something
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Tue Dec 15, 2015 1:18 pm   Post subject: RE:Switching around the sequence of numbers in an array.

You're pretty well there. Why do you think you need to use mod?
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  [ 2 Posts ]
Jump to:   


Style:  
Search: