Array problem
Author |
Message |
BlackPirate
|
Posted: Thu Jun 04, 2009 4:20 pm Post subject: Array problem |
|
|
What is it you are trying to achieve?
I want to swap the values in an array. What I want to do is that say you have Test(1) that is "1":, Test(2) that is "2", Test(3) that is "3", Test(4), "4". You would swap the default values and when you implement code like:
put Test(1)
put Test(2)
put Test(3)
put Test(4)
It would output different sequences like 1,4,2,3, 2,4,3,1, etc...
What is the problem you are having?
I don't know how to.
Describe what you have tried to solve this problem
I tried using a loop and a random number.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
<Add your code here>
|
Please specify what version of Turing you are using
4.11 |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Thu Jun 04, 2009 4:55 pm Post subject: RE:Array problem |
|
|
I bet that you are looking to do something completely different than swapping values (generating a random sequence of unique numbers perhaps?), but what the hell...
start with the simplest case of having just two variables.
code: |
var num_1 : int := 1
var num_2 : int := 2
|
how would you swap their values? Post your code. Or at least ideas. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
BlackPirate
|
Posted: Thu Jun 04, 2009 5:18 pm Post subject: Re: Array problem |
|
|
No I do want to swap the values. I used the numbers as an example, what I really want to do is swap strings (4 of them). |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Thu Jun 04, 2009 5:40 pm Post subject: RE:Array problem |
|
|
Strings are just longer numbers. The question still stands. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
|
|