Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace SelectionSort
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] array = {5, 7, 5, 9, 342, 65, 234, 64, 32};
- int positionEnd = array.Length - 1;
- int temp;
- for (int i = 0; i < positionEnd; i++)
- {
- if (array[i] > array[i + 1])
- {
- temp = array[i];
- array[i] = array[i + 1];
- array[i + 1] = temp;
- if (i != 0)
- {
- if (array[i - 1] > array[i])
- {
- i -= 2;
- }
- }
- else
- {
- continue;
- }
- }
- else
- {
- continue;
- }
- }
- foreach (int num in array)
- {
- Console.Write(num + ",");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement