I have a little problem. I want fill my array with 100 random numbers. The problem is i have a lot of the same numbers 2/4 of my array is 0 then 1/4 89 andso how is this possible ???
thanks for helping
public void arrayreverse()
{
int[] arr = new int[100];
Random r = new Random();
for (int i = 0; i < 100; i++)
{
int rand = r.Next(0, 100);
arr[i] = rand;
Array.Sort(arr);
Array.Reverse(arr);
Console.WriteLine(arr[i]);
}
Console.ReadLine();
}
Aucun commentaire:
Enregistrer un commentaire