using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{   internal class Xi
    { 
       internal char a;
       internal int count;
       internal Xi()
       { 
       
       }
       internal Xi(char ch, int count)
       {
           a = ch;
           this.count = count;
       }
    }
    class Program
    {
        static List list= new List();

         void  List_Ini()
        { 
           
           Xi xi = new Xi();
           xi.a = 'a';
           list.Add(xi);
           list.Add(new Xi('b',0));
           list.Add(new Xi('c', 0));
           list.Add(new Xi('d', 0));
           list.Add(new Xi('e', 0));
           list.Add(new Xi('f', 0));
           list.Add(new Xi('g', 0));
           list.Add(new Xi('h', 0));
           list.Add(new Xi('i', 0));
           list.Add(new Xi('j', 0));
           list.Add(new Xi('k', 0));
           list.Add(new Xi('l', 0));
           list.Add(new Xi('m', 0));
           list.Add(new Xi('n', 0));
           list.Add(new Xi('o', 0));
           list.Add(new Xi('p', 0));
           list.Add(new Xi('q', 0));
           list.Add(new Xi('r', 0));
           list.Add(new Xi('s', 0));
           list.Add(new Xi('t', 0));
           list.Add(new Xi('u', 0));
           list.Add(new Xi('v', 0));
           list.Add(new Xi('w', 0));
           list.Add(new Xi('x', 0));
           list.Add(new Xi('y', 0));
           list.Add(new Xi('z', 0));
            return;
        }

        static void Main(string[] args)
        {
            int[] letters = new int[26];

            Program p = new Program();
            p.List_Ini();
            for (int i = 0; i < 26; i++)
            {
                letters[i] = 0;
                string s;
                s = "aYou can understand subject only by creating it for yourself. The exercises play an essential role in Information Theory";
                foreach (char ch in s)
                {
                    switch (ch)
                    {
                        case 'a': letters[0]++; list[0].count++; break;
                        case 'b': letters[1]++; list[1].count++;  break;
                        case 'c': letters[2]++; list[2].count++; break;
                        case 'd': letters[3]++; list[3].count++; break;
                        case 'e': letters[4]++; list[4].count++; break;
                        case 'f': letters[5]++; list[5].count++; break;
                        case 'g': letters[6]++; list[6].count++; break;
                        case 'h': letters[7]++; list[7].count++; break;
                        case 'i': letters[8]++; list[8].count++; break;
                        case 'j': letters[9]++; list[9].count++; break;
                        case 'k': letters[10]++; list[10].count++; break;
                        case 'l': letters[11]++; list[11].count++; break;
                        case 'm': letters[12]++; list[12].count++; break;
                        case 'n': letters[13]++; list[13].count++; break;
                        case 'o': letters[14]++; list[14].count++; break;
                        case 'p': letters[15]++; list[15].count++; break;
                        case 'q': letters[16]++; list[16].count++; break;
                        case 'r': letters[17]++; list[17].count++; break;
                        case 's': letters[18]++; list[18].count++; break;
                        case 't': letters[19]++; list[19].count++; break;
                        case 'u': letters[20]++; list[20].count++; break;
                        case 'v': letters[21]++; list[21].count++; break;
                        case 'w': letters[22]++; list[22].count++; break;
                        case 'x': letters[23]++; list[23].count++; break;
                        case 'y': letters[24]++; list[24].count++; break;
                        case 'z': letters[25]++; list[25].count++; break;
                        default: break;
                    }
                }
              //  list.Sort(delegate(Xi x1, Xi x2)
             //   {
             //       return (x1.count.CompareTo(x2.count));
              //  });
                double s25 = list[25];
                double d25 = list[24].count;
                foreach (Xi x in list)
                {
                    Console.WriteLine((char)x.a + " " + x.count);
                }
                Console.Read();
                double h;
                h = s25 * Math.Log((1 / h), 2);
                Console.WriteLine(h);
            }
        }
    }
}