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

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




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
BlackPirate




PostPosted: 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).
Tony




PostPosted: Thu Jun 04, 2009 5:40 pm   Post subject: RE:Array problem

Strings are just longer numbers. The question still stands.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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  [ 4 Posts ]
Jump to:   


Style:  
Search: