Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Selection Sort
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { Console.WriteLine("Selection Sort"); int[] arr = { 2, 6, 1, 4, 3, 8 }; print(arr, "Unsorted Array"); int[] sorted = selectionSort(arr, arr.Length); print(sorted, "sorted Array"); } static int[] selectionSort(int[] arr, int n) { int temp = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (arr[i] > arr[j]) { temp = arr[j]; arr[j] = arr[i]; arr[i] = temp; } } } return arr; } static void print(int[] array,string val) { Console.WriteLine(val); for (int i = 0; i < array.Length; i++) { Console.WriteLine(array[i]); } } } }
run
|
edit
|
history
|
help
0
project euler 13, C#
2.2 Basic types: Dictionary
dsfsfsdf
c# string abbreviation
DN
NonRepeatingString
Types
Bubble Sort
c++online
insertion sort