Random Number

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
What have you tried so far? Your first step would be to fill in an array with numbers, have you done this?
#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;
}
}
Now what?
Have you read about the algorithm? Do you understand how it works?
not really..Plz help
If this is an exercise, isn't the algorithm described in your book?
I dont really have a book..my teacher said book is optional and that we can look up algorithm online
i am looking through online tutorials and learning from them .. Am I even doing this right?
Last edited on
Yes that seems to be right.
But when I run it its not shuffling the numbers. Plz help
You are not calling the my_shuffle function.
what do you mean?
Do you know what a function call is?
not really
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.
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 []?
Looks like you deleted your code?
To pass an array to the function you just put the name (without []).
Topic archived. No new replies allowed.