Реализация аффиного шифра - "программа не содержит статического метода Main, подходящего для точки входа" - C#
Формулировка задачи:
Здравствуйте. Помогите пофиксить код. Не понимаю, в чем проблем с этим Main методом.
Текст ошибки: "программа не содержит статического метода Main, подходящего для точки входа."
Вот весь код:
Заранее спасибо.
Листинг программы
- using System;
- using System.Linq;
- namespace ExercisesProject.Exercises
- {
- class AffineCipher
- {
- static void Main(string[] args);
- private static char[] Alphabet;
- public static void Run()
- {
- Console.WriteLine("AffineCipher");
- Console.WriteLine();
- Alphabet =
- Enumerable.Range('A', 26)
- .Concat(Enumerable.Range('a', 26))
- .Concat(Enumerable.Range(' ', 1))
- .Concat((new int[] { '?', '!', '.', ':', '-', '_', '(', ')' }))
- .Select(x => (char)x)
- .ToArray();
- string clearText = "Hello World! :)";
- Console.WriteLine("Original Text: " + clearText);
- Console.WriteLine();
- string cipherText = Cipher(clearText, 5, 7);
- Console.WriteLine("Ciphered Text: {0}", cipherText);
- string decipherText = Decipher(cipherText, 5, 7);
- Console.WriteLine("Deciphered Text: {0}", decipherText);
- Console.ReadKey();
- }
- static int HCF(int a, int b)
- {
- return b == 0 ? a : HCF(b, a % b);
- }
- static bool AreRelativelyPrimes(int m, int n)
- {
- return HCF(m, n) == 1;
- }
- private static bool AssertAB(int a, int b)
- {
- bool result = false;
- string message = string.Empty;
- // a and b must be in the interval 1 <= a <= Alphabet.Length
- if (a < 1 || a > Alphabet.Length)
- {
- message = string.Format("'a' must be in the interval [1,{0}]", Alphabet.Length);
- }
- else if (b < 1 || b > Alphabet.Length)
- {
- message = string.Format("'b' must be in the interval [1,{0}]", Alphabet.Length);
- }
- else if (!AreRelativelyPrimes(a, Alphabet.Length))
- {
- message = string.Format("'a' must be relatively prime to {0}", Alphabet.Length);
- }
- else
- {
- result = true;
- }
- Console.WriteLine(message);
- return result;
- }
- private static string Cipher(string clearText, int a, int b)
- {
- if (!AssertAB(a, b)) return clearText;
- string result = string.Empty;
- int m = Alphabet.Length;
- foreach (char pChar in clearText)
- {
- int p = Array.IndexOf(Alphabet, pChar);
- int c = a * p + b % m;
- int cIdx = c % Alphabet.Length;
- char cChar = Alphabet[cIdx];
- result += cChar;
- }
- return result;
- }
- private static int GetMultiplicativeInverse(int a)
- {
- int result = 1;
- for (int i = 1; i <= Alphabet.Length; i++)
- {
- if ((a * i) % (Alphabet.Length) == 1)
- {
- result = i;
- }
- }
- return result;
- }
- private static string Decipher(string cipherText, int a, int b)
- {
- if (!AssertAB(a, b)) return cipherText;
- string result = string.Empty;
- foreach (var cChar in cipherText)
- {
- int c = Array.IndexOf(Alphabet, cChar);
- int aInverse = GetMultiplicativeInverse(a);
- int pIdx = aInverse * (c - b) % Alphabet.Length;
- if (pIdx < 0)
- {
- pIdx += Alphabet.Length;
- }
- char pChar = Alphabet[pIdx];
- result += pChar;
- }
- return result;
- }
- }
- }
Решение задачи: «Реализация аффиного шифра - "программа не содержит статического метода Main, подходящего для точки входа"»
textual
Листинг программы
- static void Main(string[] args)
- {
- }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д