Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Selection Sort
- int[] arr = { 34, 11, 67, 8, 9 };
- int temp;
- for (int i = 0; i < arr.Length-1; i++)
- {
- int min_index = i;
- for (int j = i+1; j < arr.Length; j++)
- {
- if(arr[j] < arr[min_index])
- {
- temp = arr[j];
- arr[j] = arr[min_index];
- arr[min_index] = temp;
- }
- }
- }
- for (int k = 0; k < arr.Length; k++)
- {
- Console.WriteLine(arr[k]);
- }
Add Comment
Please, Sign In to add comment