Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 KB | None | 0 0
  1.  char[] alfabet = "ABCDEFGHIJKLMNOPQRSTUWXYZ".ToCharArray();
  2.             //int[] iloscLiter = new int[25] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  3.            
  4.             Console.WriteLine("Wprowadz tekst:");
  5.             String tekst = Console.ReadLine();
  6.             double[] iloscLiter = new double[25];
  7.             for (int i = 0; i < alfabet.Length;i++) iloscLiter[i] = .0;
  8.             int j = 0;
  9.             int petla = 0;
  10.             foreach ( char indeks in tekst )
  11.                 {
  12.                 bool czywszedl = false;
  13.                 while (!czywszedl)
  14.                 {
  15.                    
  16.                     if (Char.Equals(indeks, alfabet[j]))
  17.                     {
  18.                         iloscLiter[j] = iloscLiter[j]+1;
  19.                         //petla=petla+1;
  20.                         czywszedl = true;
  21.                     }
  22.                     else j++;
  23.                    
  24.                 }j = 0; petla++;
  25.                 }
  26.             double[] Srednia = new double[25];
  27.             for (int i = 0; i < alfabet.Length; i++)
  28.             {
  29.                 Srednia[i] = iloscLiter[i] / tekst.Length;
  30.             }
  31.             double max = Srednia.Max();
  32.             int przesuniecieDeszyfr = Srednia.ToList().IndexOf(max);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement