Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //1.3.9.5
- static void Main(string[] args)
- {
- foreach (int i in BubbleSort(new int[6] { 1, 2, 11, 3, 7, 10 }))
- Console.WriteLine(i);
- }
- static int[] BubbleSort(int[] array)
- {
- for (int i = 0; i < array.Length; i++)
- {
- for (int j = 0; j < array.Length - i - 1; j++)
- {
- if (array[j] > array[j + 1])
- {
- int temp = array[j];
- array[j] = array[j + 1];
- array[j + 1] = temp;
- }
- }
- }
- return array;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement