How to add in a random seed. with desired input

Pages: 12
do you mind finishing up for me, i feel like my head is about to explode, ive been trying to do this for about a week now, on and off... its ok if you dont, i dont want it to seem like im asking you to do my hw. thanks.
closed account (j3Rz8vqX)
Tips:
A for loop has three arguments:

1
2
3
4
for(/*arg#1*/;/*arg#2*/;/*arg#3*/)
{
    //Do something
}


Argument #1 holds any initialization(s) you would like to be done before the code is ran.

Argument #2 holds the limiting factor that will cause the loop to end when false.

Argument #3 processes things, such as counters, at the end of the loop.

A loop can have no arguments, but will be indefinite unless something is implemented to break out of the loop; break, exit, return.
should i add a for loop inside of the function? or modify the last for loop in the main.?
closed account (j3Rz8vqX)
Replace the assignment of arr[num] = arr[nums-1]; with a for loop.

Possibly this:
1
2
3
4
    for(int i=num;i<nums-1;i++)
    {
        arr[i] = arr[i+1];//copies next index to this index
    }


Have a good day.
Edited#2.
Last edited on
Dput wrote:
Maybe instead of swapping the missing with the last, we should implement a design to shuffle all of the remaining folks down a notch?

I don't believe that's necessary. The code to swap with the last and decrement num_of_names seems reasonable. I tested with various boundary conditions (rand=0, rand=4) and the program behaved as expected.

I'm still trying to understand the failure conditions. I would suggest adding a count after line 9 so we know the random number generated. Knowing the random number generated might help identify the failure condition. Also, I found it helpful to enter the names in alphabetical order so that when the "not called" list was displayed it was easy to determine if it was correct.
closed account (j3Rz8vqX)
The previously unintended error was that it would swap the last person with the selected, whereas OP wanted to shuffle the remaining user an index closer to zero; ideally moving the "Cat" person to the end while keeping the remaining people within the same order.

It is really the OPs choice whether or not OP wants to swap the last and selected or to shuffle the selected person the the end.

Either way, I think a solution was found.
Last edited on
ok just got back from work, ill try them out, the deadline is midnight, i have to do another program but im not going to do that one. ill message back if everything went ok. ty<3 thanks for the help everyone.
YES IT FINALLY QWORKLED !! TY
closed account (j3Rz8vqX)
Your welcome =D
Topic archived. No new replies allowed.
Pages: 12