Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp3
- {
- class Program
- {
- static void Exchange(int a, int b) // менять местами.
- {
- int temp = a;
- a = b;
- b = temp;
- }
- static int[] Bubbledown(int[] arr)
- {
- int n = arr.Length;
- for (int i = 1; i < n; i++)
- {
- for (int j = 0; j < n - i; j++)
- {
- if (arr[i] <= arr[j + 1])
- Exchange( arr[j], arr[i + 1]);
- }
- }
- return arr;
- }
- static void Main(string[] args)
- {
- int[] arr = {2, 4, 1, 4, 5, 10 };
- Console.WriteLine(Bubbledown(arr));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement