Hello,
I need help!!! I have a program that uses an array for the user to enter in 5 integers. After those integers are added I want to sort them using a bubble sort. My problem is I'm really confused on where I place my bubble sort? Any help would be appreciated.Thank you!
static void Main(string[] args)
{
string myName = "";
int[] integers = new int[5];
int Sum = 0;
int temp;
Console.WriteLine("What is your name?");
myName = Console.ReadLine();
for (int i = 0; i < integers.Length; i++)
{
while (Sum < 10 || Sum > 50)
{
Console.WriteLine("Please enter {0} integers between 10 and 50"
, integers.Length - i);
Sum = Convert.ToInt32(Console.ReadLine());
}
integers[i] = Sum;
Sum = 0;
}
for (int i = 0; i < integers.Length; i++)
{
for (int pass = 1; pass <= integers.Length - 2; pass++)
{
for (int j = 0; j <= integers.Length - 2; j++)
{
if (integers[j] > integers[j = 1])
{
temp = integers[j + 1];
integers[j + 1] = integers[j];
integers[j] = temp;
}
}
}
}
Console.WriteLine("Your name is {0}.", myName);
Console.ReadKey();