vendredi 22 février 2019

Add to array in random order

Lets suppose that I have an array of arrays in C# (10x10 for example). I need to fill it with numbers from 1 to 50 (each numbers will be there twice) and these numbers must be on random position. How can I do this? I suppose that this could be ok: choose random position and then put there a number if the position is empty. If it is not empty, choose another position. But I think it is very complicated and also maximum time complexity is terrible. There must be better way, is there? I would really appreciate if your advice includes only elementary C# knowledge as this is my first week with this language.

Thanks for any advice.




Aucun commentaire:

Enregistrer un commentaire