Mordred Posted September 27, 2017 Posted September 27, 2017 How would one go about this? Yes im stupid as fuck
HunterRS Posted September 27, 2017 Posted September 27, 2017 (edited) 6 minutes ago, upotudrop said: How would one go about this? Yes im stupid as fuck private void SortArrayWithShellSort() { int[] array = { 297,183, 464 }; ShellSort(array); } private void ShellSort(int[] array) { int n = array.Length; int gap = n / 2; int temp; while (gap > 0) { for (int i = 0; i + gap < n; i++) { int j = i + gap; temp = array[j]; while (j - gap >= 0 && temp < array[j - gap]) { array[j] = array[j - gap]; j = j - gap; } array[j] = temp; } gap = gap / 2; } } From google. Now simply add a console.writeline of the array after each insertion. EDIT: static void show_array_elements(int[] arr) { foreach (var element in arr) { Console.Write(element + " "); } Console.Write("\n"); } For printing the array Edited September 27, 2017 by HunterRS
Product Posted September 27, 2017 Posted September 27, 2017 Eh more info? What part do you not understand? Do you even have an IDE? I assume this is for school, and if so I'd recommend you to try yourself first, information how to solve all parts of your assignment can be googled. Just copy-pasting something someone gives you will just give you more trouble your next assignment.
HunterRS Posted September 27, 2017 Posted September 27, 2017 (edited) 7 minutes ago, Product said: Eh more info? What part do you not understand? Do you even have an IDE? I assume this is for school, and if so I'd recommend you to try yourself first, information how to solve all parts of your assignment can be googled. Just copy-pasting something someone gives you will just give you more trouble your next assignment. You have to start somewhere, no one should just copy paste but going over the code and understanding what each part of it does will help you understand and handle this type of assignments in the future. Edited September 27, 2017 by HunterRS