grigorb57

Bubble sort

Mar 1st, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp40
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] arr = new int[6] { 5, 4, 3, 2, 0, 1 };
  14.             int shit = 0;
  15.  
  16.             for (int i = 0; i < arr.Length; i++)
  17.             {
  18.                 for (int j = 0; j < arr.Length; j++)
  19.                 {
  20.                     if (arr[i] < arr[j])
  21.                     {
  22.                         shit = arr[i];
  23.                         arr[i] = arr[j];
  24.                         arr[j] = arr[i];
  25.                     }
  26.                 }
  27.             }  
  28.             for (int i = 0; i < arr.Length; i++)
  29.             {
  30.                 Console.Write(i + " ");
  31.             }
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment