Hello, I am trying to fill an array with 20 unique random values between 1 and 60. I know what I need to do to get this to work, but I'm not sure how to do it. Here's what I've got:
void fillArray( int arr[], int size)
{
int arr2[20];
bool found[20] = {false};
for (int i = 0; i < size; i++)
{
arr[i] = rand() % 60 + 1;
arr2[i] = arr[i];
for (int j = 0; j < size; j++) // check for duplicates in array
{
if (arr[i] == arr[j])
{
found[i] = true;
arr[i] = rand() % 60 + 1;
}
}
}
}
My program checks an array for duplicates, but doesn't check the duplicates to see if they themselves are duplicates. How might I go about doing that? Thank you for your time!