## sfurlow2

How do you walk an array?

## Ancient Dragon 5,243

That probably means to create a loop and inspect each element. For example:

``````int array[5];
for(int i = 0; i < 5; i++)
cout << array[i] << " ";``````

## sfurlow2

we're supposed to create an array of 1000 integers, and then shuffle it so that each number appears only once, except in a random order. Our instructions say walk an array once, and then swap the number at the current index with a random index between 0 and 999. What does that mean?

## VernonDozier 2,218

we're supposed to create an array of 1000 integers, and then shuffle it so that each number appears only once, except in a random order. Our instructions say walk an array once, and then swap the number at the current index with a random index between 0 and 999. What does that mean?

"Walk" is probably a synonym for "traverse", which is to go through the array one element at a time and do whatever with that element, which in your case is to do some swapping so the array is randomized. I've never heard the term "walk". Maybe it has some technical meaning, but I doubt it. It probably means "traverse". I'd ignore the term "walk" and just focus on the best way to randomize the order of 1000 integers. There are several ways to do that and I wouldn't be surprised if there are several threads on Daniweb. Card games involve similar tasks and there are lots of threads on here dealing with good ways to shuffle cards. Here's one that may help. You'll have to tweak it to your situation.