I have a task where I have to fill an array with 16 random numbers, in random indexes. 4 of those elements have to be -1, and all the other left indexes have to be 0-15, but different from another, meaning it is impossible for two different indexes have the same number (0-15). Filling 4 random indexes is easy, and so is filling the other indexes with random numbers between 0-15, but how do I feel them in such way that they are necessarily different from each other?
There are also two more conditions which complicate this task much more, the first one is that the number of the index cannot have the same number within it, meaing arr[3]=3 is impossible, and another condition is that (m[p]==j && m[j]==mp && m!=j) is something that we must take care of so it won't happen, for example, if arr[2]=0 and arr[0]=2, we have to change it so it won't happen.
I'm so confused, I had literally sat 8 hours yesterday infront of this, trying all sort of things, and I have no idea, honestly..
Aucun commentaire:
Enregistrer un commentaire