Реализация аффиного шифра - "программа не содержит статического метода Main, подходящего для точки входа" - C#

Узнай цену своей работы

Формулировка задачи:

Здравствуйте. Помогите пофиксить код. Не понимаю, в чем проблем с этим Main методом. Текст ошибки: "программа не содержит статического метода Main, подходящего для точки входа." Вот весь код:
Листинг программы
  1. using System;
  2. using System.Linq;
  3. namespace ExercisesProject.Exercises
  4. {
  5. class AffineCipher
  6. {
  7. static void Main(string[] args);
  8. private static char[] Alphabet;
  9.  
  10. public static void Run()
  11. {
  12. Console.WriteLine("AffineCipher");
  13. Console.WriteLine();
  14. Alphabet =
  15. Enumerable.Range('A', 26)
  16. .Concat(Enumerable.Range('a', 26))
  17. .Concat(Enumerable.Range(' ', 1))
  18. .Concat((new int[] { '?', '!', '.', ':', '-', '_', '(', ')' }))
  19. .Select(x => (char)x)
  20. .ToArray();
  21. string clearText = "Hello World! :)";
  22. Console.WriteLine("Original Text: " + clearText);
  23. Console.WriteLine();
  24. string cipherText = Cipher(clearText, 5, 7);
  25. Console.WriteLine("Ciphered Text: {0}", cipherText);
  26. string decipherText = Decipher(cipherText, 5, 7);
  27. Console.WriteLine("Deciphered Text: {0}", decipherText);
  28. Console.ReadKey();
  29. }
  30. static int HCF(int a, int b)
  31. {
  32. return b == 0 ? a : HCF(b, a % b);
  33. }
  34. static bool AreRelativelyPrimes(int m, int n)
  35. {
  36. return HCF(m, n) == 1;
  37. }
  38. private static bool AssertAB(int a, int b)
  39. {
  40. bool result = false;
  41. string message = string.Empty;
  42. // a and b must be in the interval 1 <= a <= Alphabet.Length
  43. if (a < 1 || a > Alphabet.Length)
  44. {
  45. message = string.Format("'a' must be in the interval [1,{0}]", Alphabet.Length);
  46. }
  47. else if (b < 1 || b > Alphabet.Length)
  48. {
  49. message = string.Format("'b' must be in the interval [1,{0}]", Alphabet.Length);
  50. }
  51. else if (!AreRelativelyPrimes(a, Alphabet.Length))
  52. {
  53. message = string.Format("'a' must be relatively prime to {0}", Alphabet.Length);
  54. }
  55. else
  56. {
  57. result = true;
  58. }
  59. Console.WriteLine(message);
  60. return result;
  61. }
  62. private static string Cipher(string clearText, int a, int b)
  63. {
  64. if (!AssertAB(a, b)) return clearText;
  65. string result = string.Empty;
  66. int m = Alphabet.Length;
  67. foreach (char pChar in clearText)
  68. {
  69. int p = Array.IndexOf(Alphabet, pChar);
  70. int c = a * p + b % m;
  71. int cIdx = c % Alphabet.Length;
  72. char cChar = Alphabet[cIdx];
  73. result += cChar;
  74. }
  75. return result;
  76. }
  77. private static int GetMultiplicativeInverse(int a)
  78. {
  79. int result = 1;
  80. for (int i = 1; i <= Alphabet.Length; i++)
  81. {
  82. if ((a * i) % (Alphabet.Length) == 1)
  83. {
  84. result = i;
  85. }
  86. }
  87. return result;
  88. }
  89. private static string Decipher(string cipherText, int a, int b)
  90. {
  91. if (!AssertAB(a, b)) return cipherText;
  92. string result = string.Empty;
  93. foreach (var cChar in cipherText)
  94. {
  95. int c = Array.IndexOf(Alphabet, cChar);
  96. int aInverse = GetMultiplicativeInverse(a);
  97. int pIdx = aInverse * (c - b) % Alphabet.Length;
  98. if (pIdx < 0)
  99. {
  100. pIdx += Alphabet.Length;
  101. }
  102. char pChar = Alphabet[pIdx];
  103. result += pChar;
  104. }
  105. return result;
  106. }
  107. }
  108. }
Заранее спасибо.

Решение задачи: «Реализация аффиного шифра - "программа не содержит статического метода Main, подходящего для точки входа"»

textual
Листинг программы
  1. static void Main(string[] args)
  2. {
  3. }

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

8   голосов , оценка 4.25 из 5

Нужна аналогичная работа?

Оформи быстрый заказ и узнай стоимость

Бесплатно
Оформите заказ и авторы начнут откликаться уже через 10 минут
Похожие ответы