Advertisement
Askor

NewHw20

Apr 15th, 2022
649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         int[] array = { 85, 2, 3, 12, -15, 0, 5, 87, 12, 45, 12, 789, -100, 1, 8, 56, 36, 86 };
  8.         int temp;
  9.  
  10.         for (int i = 0; i < array.Length; i++)
  11.         {
  12.             Console.Write($"{array[i]}, ");
  13.         }
  14.  
  15.         for (int i = 0; i < array.Length; i++)
  16.         {
  17.             for (int j = i + 1; j < array.Length; j++)
  18.             {
  19.                 if (array[i] > array[j])
  20.                 {
  21.                     temp = array[i];
  22.                     array[i] = array[j];
  23.                     array[j] = temp;
  24.                 }
  25.             }
  26.         }
  27.  
  28.         Console.WriteLine();
  29.  
  30.         for (int i = 0; i < array.Length; i++)
  31.         {
  32.             Console.Write($"{array[i]}, ");
  33.         }
  34.  
  35.         Console.ReadKey();
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement