Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
kamikaze123
kamikaze123's Profile
1
Posts
1
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
randomize array
[5 Replies]
17-Apr-2012 06:54 AM
Forum:
Programming Questions
hey guys...im having trouble with creating a method that when passed an array randomizes the order of all the items in the
array.
void setup() {
int[] a = new int[3];
for(int i=0; i<a.length; i++)
a[i] = i+1;
display(a); //displays 1 2 3
randomize(a);
display(a);
the goal is to create a method for randomize(a)
and this is what i have:
void randomize (int[]value){
for(int i=0;i<value.length;i++)
value[i] = (int)random(3);
}
what do i do next so that it shows this in the console:
/*the second display method can display either
! 1 2 3 or
! 1 3 2 or
! 2 1 3 or
! 2 3 1 or
! 3 1 2 or
! 3 2 1
! */
«Prev
Next »
Moderate user : kamikaze123
Forum