I'm having a bit of difficulty. I'm trying to make a program that takes a command line argument and then shuffles it then prints the shuffled numbers. However, the numbers cannot follow in oder. Ie: 2 cannot follow 3, 6 cannot follow 5, etc.
Here is my code:
My problem, I do not know what to put in where it says "HELP" in bold, red letters. I've tried numerous things! Each time, to no avail. Please help!
Here is my code:
Code:
int numSongs = Integer.parseInt(args[0]);
int[] song = new int[numbSongs];
for (int position = 0; position < numbSongs; position++) {
int list = position;
song[position] = list;
}
for (int current = 0; current < numbSongs; current++) {
int swap = current + (int) (Math.random() * (numbSongs - current));
int tempSong = song[current];
song[current] = song[swap];
song[swap] = tempSong;
if (song[current] == song[swap+1] || song[current] == song[swap-1])
{ [B][COLOR="Red"]HELP![/COLOR][/B] }
else
{ System.out.println(song[swap]); }
System.out.println(song[current] + " ");
}
My problem, I do not know what to put in where it says "HELP" in bold, red letters. I've tried numerous things! Each time, to no avail. Please help!