using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication62 { class Program { public static void test(int[] ar, int no){ int i, c, root, tmp; for (i = 1; i <= no; i++){ c = i; do{ root=(c - 1) / 2; if (ar[root] < ar[c]){ tmp = ar[root]; ar[root] = ar[c]; ar[c] = tmp; } c = root; } while(c!=0); } } public static void wypisz(int[] ar, int no){ int i; for (i = 0; i <= no; i++){ Console.WriteLine(ar[i]); } } static void Main(string[] args) { int[] ar = { 5, 8, 7, 0, 1 }; int[] a = new int[5]; int i; test(ar, 4); wypisz(ar, 4); for (i = 0; i <= 4; i++){ test(ar, 4-i); a[i] = ar[0]; ar[0] = ar[4 - i]; } Console.WriteLine("==========================="); wypisz(a, 4); Console.ReadLine(); } } }