Сортировка

Привожу код лабораторной по сортировке одномерного массива, единственный недочет в этой работе - неправильно работают некоторые счетчики кол-ва перестановок и кол-ва сравнений)
Я считаю, что это одна из работ, заслуживающих внимание начинающих программистов)

int[] a=new int[4],b=new int[4],c=new int[4],d=new int[4],e=new int[4],f=new int[4];
            int l = 0;
            int k = 0;
            Random rnd = new Random();
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = rnd.Next(102);
                b[i] = c[i] = d[i] = e[i]=f[i] = a[i];
                Console.Write(a[i] + " ");
            }
            Console.WriteLine();
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.WriteLine("Сортировка методом Пузырька");
            for(int i=0;i<a.Length;i++)
                for (int j = 0; j < a.Length - 1; j++)
                {
                    k++;
                    if (a[j] > a[j + 1])
                    {
                        int tmp = a[j];
                        a[j] = a[j+1];
                        a[j + 1] = tmp;
                        l++;
                    }
                }
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Green;
            for (int i = 0; i < a.Length; i++)
            {
                Console.Write(a[i] + " ");
            }
            Console.ResetColor();
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine();
            Console.WriteLine("Количество перестановок: "+l);
            Console.WriteLine("Количество сравнений: " + k);
            Console.ReadLine();
            int m = 0,p=0;
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.WriteLine("Сортировка Выбором");
            Console.WriteLine();
            for (int i = 0; i < b.Length; i++)
            {
                int min = i; int x = b[i];
                for (int j = i + 1; j < b.Length; j++)
                {
                    if (b[j] < x)
                    {
                        min = j; x = b[j];
                    }
                    m++;
                }
                b[min] = b[i]; b[i] = x;
                p++;
            }
            Console.ForegroundColor = ConsoleColor.Green;
            for (int i = 0; i < b.Length; i++)
            {
                Console.Write(b[i] + " ");
            }
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Количество перестановок: " + (p-1));
            Console.WriteLine("Количество сравнений: " + m);
            Console.ReadLine();
            int pr = 0,sr=0;
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.WriteLine();
            Console.WriteLine("Сортировка Вставкой");
            for (int i = 1; i < c.Length; i++)
            {
               int x = c[i];
                int j = i - 1;
                sr++;
                while (j >= 0 && c[j] > x)
                {
                    c[j + 1] = c[j];
                    j--;
                    pr++;
                }
                c[j + 1] = x;
            }
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine();
            for (int i = 0; i < c.Length; i++)
            {
                Console.Write(c[i] + " ");
            }
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Количество перестановок: " + (sr+pr));
            Console.WriteLine("Количество сравнений: " + (pr+c.Length-1));
            Console.ReadLine();
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.WriteLine("Сортировка методом Шелла");
            int step = d.Length / 2;
            int t = 0,u=0;
            Console.WriteLine();
            while (step > 0)
            {
                for (int i = 0; i < (d.Length - step); i++)
                {
                    int j = i;
                    while ((j >= 0) && (d[j] > d[j + step]))
                    {
                        int tmp = d[j];
                        d[j] = d[j + step];
                        d[j + step] = tmp;
                        j--;
                        t++;
                    }
                    u++;
                }
                step = step / 2;
            }
            Console.ForegroundColor = ConsoleColor.Green;
            for (int i = 0; i < d.Length; i++)
            {
                Console.Write(d[i] + " ");
            }
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine();
            Console.WriteLine("Количество перестановок: " + t);
            Console.WriteLine("Количество сравнений: " + u);
            Console.ReadLine();
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.WriteLine("Сортировка методом Шейкера");
            int l2 = 1, r2 = e.Length - 1;
            int k2=e.Length-1,tmp2;
            int srav1 = 0, srav2 = 0, pere1 = 0, pere2 = 0,srav,pere;
            do
            {
               
                for (int i = r2; i > 0; i--)
                {
                    srav1++;
                    if (e[i - 1] > e[i])
                    {
                        tmp2 = e[i-1];
                        e[i-1] = e[i];
                        e[i] = tmp2;
                        k2 = i;
                        pere1++;
                    }
                   
                }
           
                l2 = k2 + 1;
                for (int i = 1; i <= r2; i++)
                {
                    srav2++;
                    if (e[i - 1] > e[i])
                    {
                        tmp2 = e[i - 1];
                        e[i - 1] = e[i];
                        e[i] = tmp2;
                        k2 = i;
                        pere2++;
                    }
                }
                    r2 = k2 - 1;
               
            }
            while (l2 < r2);
            Console.ForegroundColor = ConsoleColor.Green;
            for (int i = 0; i < e.Length; i++)
            {
                Console.Write(e[i] + " ");
            }
            srav = srav1 + srav2;
            pere = pere1 + pere2;
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine();
            Console.WriteLine("Количество перестановок: " + pere);
            Console.WriteLine("Количество сравнений: " + srav);
            Console.ReadLine();
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.WriteLine("Сортировка методом улучшенного Пузырька");
            bool tr = true;
            int sravn = 0, peres = 0;
            while (tr)
            {
                tr = false;
                for (int i = 0; i <f.Length-1; i++)
                {
                    sravn++;
                    if (f[i] > f[i + 1])
                    {
                        int tm2 = f[i];
                        f[i] = f[i + 1];
                        f[i + 1] = tm2;
                        tr = true;
                        peres++;
                    }
                }
            }
            Console.ForegroundColor = ConsoleColor.Green;
            for (int i = 0; i < e.Length; i++)
            {
                Console.Write(f[i] + " ");
            }
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine();
            Console.WriteLine("Количество перестановок: " + peres);
            Console.WriteLine("Количество сравнений: " + sravn);
            Console.ReadLine();