Thanks again for the help, I did have other issues with the code, your guidence really helped though. For awhile I had a infinite loop, then I had a ; after a while, which threw exceptions, but eventually I got it, Again, thanks for the response. Here is my finished code:
static long statements = 0;
static void Main(string[] args)
{
int[] Number = new int[1000]; Random numb = new Random();
for (int i = 0; i < Number.Length; i++)
{
Number[i] = numb.Next(100, 999);
Console.WriteLine(Number[i]); }
ShellSort(Number);
Console.WriteLine("Press any key to display the first twenty numbers");
Console.ReadLine();
for (int j = 0; j < 20; j++)
{
Console.WriteLine(Number[j]);
}
ShellSort(Number);
statements = 0;
Console.WriteLine("Press any key to display the last twenty numbers sorted");
Console.ReadLine();
for (int k = 980; k < 1000; k++)
{
Console.WriteLine(Number[k]);
}
ShellSort(Number);
Console.ReadLine();
}
public static void ShellSort(int [] values)
{
int j;
int temp;
int increment = 3;
while (increment > 0)
{
for (int index = 0; index < values.Length; index++)
{
j = index;
temp = values[index];
while ((j >= increment) && values[j - increment] > temp)
{
values[j] = values[j] - increment;
j = j - increment;
statements++;
}
values[j] = temp;
statements++;
}
if (increment / 2 != 0)
increment = increment / 2;
else if (increment == 1)
increment = 0;
else
increment = 1;
statements++;
}
Console.WriteLine(" There are a total of {0} statements in Shell Sort.", statements);
Console.ReadLine();
}
}
}