reverse
So im trying to reverse array random numbers, but it keeps giving wrong output, so i have 10 array and 10 random numbers but when i try to reverse it gives me 10 arrays, but worst part is it doesnt start from 0 but from 10, before it shows all 0 and only then result is reversed
Random rand = new Random(20);
int[] array = new int[20];
for (int i = 0; i < 10; i++)
{
int x = rand.Next(20);
array[i] = x;
Console.WriteLine($"Mas[{i + 1}] = {x}");
}
Array.Reverse(array);
// Display the reversed array
Console.WriteLine("Reversed array:");
for (int i = 1; i < array.Length; i++)
{
Console.WriteLine($"Mas[{i + 1}] = {array[i]}");
}
2 Replies
why are you making an array with a length of 20 but you only use 10?
well i noticed that, hahah thanks❤️