Switching around the sequence of numbers in an array.
Author |
Message |
SYZekrom
|
Posted: 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 |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: 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? |
|
|
|
|
![](images/spacer.gif) |
|
|