Jul 2, 2014 at 2:13am UTC
How to do a numbers input, randomize the numbers using something called Fisher Yates shuffle? This is my first time using this shuffle so I dont know how to start the algorithm
Jul 2, 2014 at 2:41am UTC
What have you tried so far? Your first step would be to fill in an array with numbers, have you done this?
Jul 2, 2014 at 9:51am UTC
#include <iostream>
using namespace std;
int main()
{
const int arr_size = 10;
int arr[arr_size] = {1,2,3,4,5,6,7,8,9,10};
for(int count = 0; count < arr_size; count++)
{
cout << " "<<arr[count]<<endl;
}
}
Jul 2, 2014 at 10:22am UTC
Have you read about the algorithm? Do you understand how it works?
Jul 2, 2014 at 10:31am UTC
If this is an exercise, isn't the algorithm described in your book?
Jul 2, 2014 at 10:38am UTC
I dont really have a book..my teacher said book is optional and that we can look up algorithm online
Jul 2, 2014 at 11:12am UTC
i am looking through online tutorials and learning from them .. Am I even doing this right?
Last edited on Jul 2, 2014 at 1:25pm UTC
Jul 2, 2014 at 11:44am UTC
Yes that seems to be right.
Jul 2, 2014 at 12:34pm UTC
But when I run it its not shuffling the numbers. Plz help
Jul 2, 2014 at 12:34pm UTC
You are not calling the my_shuffle function.
Jul 2, 2014 at 12:57pm UTC
Do you know what a function call is?
Jul 2, 2014 at 1:12pm UTC
It's the code that makes the function run.
On line 26 you are calling rand and my_swap.
When a program starts only the main function is automatically called.
In main you do not call my_shuffle so the code in that function will never run.
I suspect you want to call my_shuffle on line 8.
Jul 2, 2014 at 1:18pm UTC
I am not sure how to call an array
i know if I am called my_swap I write is like this my_swap(a,b);
But how do I do it for []?
Jul 2, 2014 at 2:26pm UTC
Looks like you deleted your code?
Jul 2, 2014 at 3:10pm UTC
To pass an array to the function you just put the name (without []).