The numbers are randomly generated in the vector, however when I call the bublle function to sort the result it returns 0. Can someone help me ????
using System;
namespace BubbleSort_CSharp
{
class Program
{
static void Main(string[] args)
{
int[] vetor = new int[10];
Random rnd = new Random();
Console.WriteLine("Vetor Desordenado\n");
for (int i = 0; i <= vetor.Length; i++)
{
Console.WriteLine("Elemento: {0}", rnd.Next(1, 100));
}
bubbleSort(vetor, vetor.Length);
Console.WriteLine("\nVetor Ordenado\n");
for (int i = 0; i <= vetor.Length; i++)
{
Console.WriteLine("Elemento: {0} ", vetor[i]);
}
Console.ReadLine();
}
static void bubbleSort(int[] vetor, int length)
{
int trocas = 0;
for (int i = 0; i < length - 1; i++)
{
for (int j = 0; j < length - (i + 1); j++)
{
if (vetor[j] > vetor[j + 1])
{
trocas = vetor[j];
vetor[j] = vetor[j + 1];
vetor[j + 1] = trocas;
}
}
}
}
}
}