Danielos168

Bubble-Sort

Nov 17th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.46 KB | None | 0 0
  1.  static void Bubble(int[] tab, int n)
  2.         {
  3.             for (int i = 1; i < n; i++)
  4.             {
  5.                 for (int j = n-1; j >= 1; j--)
  6.                 {
  7.                     if (tab[j] < tab[j - 1])
  8.                     {
  9.                         int temp;
  10.                         temp = tab[j - 1];
  11.                         tab[j - 1] = tab[j];
  12.                         tab[j] = temp;
  13.                     }
  14.                 }
  15.             }
  16.         }
Advertisement
Add Comment
Please, Sign In to add comment