Advertisement
zalakirovka1

Untitled

Nov 2nd, 2020
2,176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp3
  4. {
  5.     class Program
  6.     {
  7.         static void Exchange(int a,  int b) // менять местами.
  8.         {
  9.             int temp = a;
  10.             a = b;
  11.             b = temp;
  12.         }
  13.  
  14.  
  15.  
  16.         static int[] Bubbledown(int[] arr)
  17.         {
  18.             int n = arr.Length;
  19.             for (int i = 1; i < n; i++)
  20.             {
  21.                 for (int j = 0; j < n - i; j++)
  22.                 {
  23.                     if (arr[i] <= arr[j + 1])
  24.                         Exchange( arr[j],  arr[i + 1]);
  25.                 }
  26.             }
  27.             return arr;
  28.         }
  29.        
  30.         static void Main(string[] args)
  31.         {
  32.             int[] arr = {2, 4, 1, 4, 5, 10 };
  33.             Console.WriteLine(Bubbledown(arr));
  34.         }
  35.  
  36.     }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement