Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class texto
- {
- public string let;
- public int nlet;
- public int sh;
- public texto(string a, int b, int c)
- {
- let = a;
- nlet = b;
- sh = c;
- }
- }
- class Test
- {
- public static void Main()
- {
- Console.WriteLine("Введите текст");
- string c = Console.ReadLine();
- int g = c.Length;
- for (int i = 0; i < c.Length; i++)
- {
- if (c[i] == ' '||c[i]==','||c[i]=='.')
- {
- g--;
- }
- }
- string v = c;
- c = v.ToLower();
- Console.WriteLine("В тексте {0} букв", g);
- texto[] m = new texto[g-1];
- int y = 0;
- int prov = 0;
- double s = 0;
- for (int i = 1; i <c.Length; i++)
- {
- prov = 0;
- if (c[i] != ' ' && c[i] != ',' && c[i] != '.'&& c[i-1] != ' ' && c[i-1] != ',' && c[i-1] != '.')
- {
- if (y > 0)
- {
- for (int t = 0; t <= y - 1; t++)
- {
- if (String.Concat(c[i - 1], c[i]) == m[t].let)
- {
- m[t].nlet++;
- prov++;
- s++;
- }
- }
- }
- if (prov == 0)
- {
- int f = 0;
- int a = 3;
- m[y] = new texto(String.Concat(c[i - 1], c[i]), 1, y);
- while (f < c.Length)
- {
- if (c[f] == m[y].sh)
- {
- f = 0;
- m[y].sh = y + a;
- a++;
- }
- f++;
- }
- if (i < c.Length - 1)
- {
- y++;
- }
- s++;
- }
- }
- }
- s = s / y;
- string v = c;
- Console.WriteLine();
- Console.WriteLine("Шифры");
- Console.WriteLine();
- int r = 0;
- for (int i = 0; i < y; i++)
- {
- if (m[i].nlet > s)
- {
- if (r % 2 == 0)
- {
- v = c.Replace(m[i].let, m[i].sh.ToString());
- Console.WriteLine("Шифр {0} -> '{1}'", m[i].sh, m[i].let);
- r++;
- }
- else
- {
- c = v.Replace(m[i].let, m[i].sh.ToString());
- Console.WriteLine("Шифр {0} -> '{1}'", m[i].sh, m[i].let);
- r++;
- }
- }
- }
- if (r > 0)
- {
- Console.WriteLine();
- Console.WriteLine("Итоговый текст");
- if (r % 2 == 0)
- {
- Console.WriteLine(c);
- }
- else
- {
- Console.WriteLine(v);
- }
- }
- else
- {
- Console.WriteLine("Повторяющихся комбинаций нет");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement