Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.47 KB | None | 0 0
  1. //1.3.9.5
  2.         static void Main(string[] args)
  3.         {
  4.             foreach (int i in BubbleSort(new int[6] { 1, 2, 11, 3, 7, 10 }))
  5.                 Console.WriteLine(i);
  6.         }
  7.  
  8.         static int[] BubbleSort(int[] array)
  9.         {
  10.             for (int i = 0; i < array.Length; i++)
  11.             {
  12.                 for (int j = 0; j < array.Length - i - 1; j++)
  13.                 {
  14.                     if (array[j] > array[j + 1])
  15.                     {
  16.                         int temp = array[j];
  17.                         array[j] = array[j + 1];
  18.                         array[j + 1] = temp;
  19.                     }
  20.                 }
  21.             }
  22.             return array;
  23.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement