Does not contain a static 'Main' method suitable for an entry poin - C#

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

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

Хелп! Помогите студенту! Сижу уже битый час, не пойму в чём дело. При компиляции, выдаёт ошибку: does not contain a static 'Main' method suitable for an entry point ConsoleApplication4 Помогите сделать проект, ибо я уже пошел за валидолом
Листинг программы
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace ConsoleApplication4
  6. {
  7. public class Matrix
  8. {
  9. public float[,] matrix = null; // хранение данных
  10. public int CountColumn { get; private set; } // количество столбцов
  11. public int CountRow { get; private set; } // количество строк
  12. public Matrix(int x = 1, int y = 1, bool autoGeneration = true, int startGen = 1) // конструктор с параметрами
  13. {
  14. if (autoGeneration) generator(x, y, startGen);
  15. else
  16. matrix = new float[x, y];
  17. CountColumn = y;
  18. CountRow = x;
  19. }
  20. public float this[int x, int y] // получить элемент по индексам
  21. {
  22. get { return matrix[x, y]; }
  23. set { matrix[x, y] = value; }
  24. }
  25. public static Matrix operator +(Matrix x1, Matrix x2) // для сложения матриц
  26. {
  27. if (x1.CountRow != x2.CountRow || x1.CountColumn != x2.CountColumn) throw new ArgumentException("Несоответствующие матрицы");
  28. Matrix ret = new Matrix(x1.CountRow, x1.CountColumn, false); // новая матрица
  29. for (int i = 0; i < x1.CountRow; i++)
  30. for (int j = 0; j < x1.CountColumn; j++)
  31. {
  32. ret[i, j] = x1[i, j] + x2[i, j]; // сложение
  33. }
  34. return ret;
  35. }
  36. public static Matrix operator +(Matrix x1, int x2) // сложения матрицы и числа
  37. {
  38. Matrix ret = new Matrix(x1.CountRow, x1.CountColumn, false);
  39. for (int i = 0; i < x1.CountRow; i++)
  40. for (int j = 0; j < x1.CountColumn; j++)
  41. {
  42. ret[i, j] = x1[i, j] + x2;
  43. }
  44. return ret;
  45. }
  46. public static Matrix operator -(Matrix x1, Matrix x2) // для вычитания матриц
  47. {
  48. if (x1.CountRow != x2.CountRow || x1.CountColumn != x2.CountColumn) throw new ArgumentException("Несоответствующие матрицы");
  49. Matrix ret = new Matrix(x1.CountRow, x1.CountColumn, false);
  50. for (int i = 0; i < x1.CountRow; i++)
  51. for (int j = 0; j < x1.CountColumn; j++)
  52. {
  53. ret[i, j] = x1[i, j] - x2[i, j]; // вычитаем из каждого элемента соответствующий
  54. }
  55. return ret;
  56. }
  57. public static Matrix operator -(Matrix x1, int x2) // вычитание числа из матрицы
  58. {
  59. Matrix ret = new Matrix(x1.CountRow, x1.CountColumn, false);
  60. for (int i = 0; i < x1.CountRow; i++)
  61. for (int j = 0; j < x1.CountColumn; j++)
  62. {
  63. ret[i, j] = x1[i, j] - x2; // вычитаем из каждого числа
  64. }
  65. return ret;
  66. }
  67. public static bool operator ==(Matrix x1, Matrix x2) // оператор на равенство
  68. {
  69. if (x1.CountColumn != x2.CountColumn || x1.CountRow != x2.CountRow)
  70. return false;
  71. for (int i = 0; i < x1.CountRow; i++)
  72. for (int j = 0; j < x1.CountColumn; j++)
  73. {
  74. if (x1[i, j] != x2[i, j]) // сравниваем каждый элемент
  75. return false;
  76. }
  77. return true;
  78. }
  79. public static bool operator !=(Matrix x1, Matrix x2)// оператор на неравенство
  80. {
  81. return (!(x1 == x2));
  82. }
  83. public Matrix Inverse() // получение обратной матрицы
  84. {
  85. if (CountRow != CountColumn) throw new ArgumentException("Обратная матрица существует только для квадратных, невырожденных, матриц.");
  86. Matrix matrix = new Matrix(CountRow, CountColumn); //Делаем копию исходной матрицы
  87. float determinant = this.Determinant(); // вычисление определителя
  88. if (determinant == 0)
  89. return matrix; //Если определитель == 0 - матрица вырожденная
  90. for (int i = 0; i < CountColumn; i++)
  91. {
  92. for (int t = 0; t < CountRow; t++)
  93. {
  94. Matrix tmp = this.Exclude(i, t); //получаем матрицу без строки i и столбца t
  95. matrix[t, i] = tmp.Determinant() / determinant;
  96. if (((i + t) % 2) == 1)
  97. {
  98. matrix[t, i] *= -1; // меняем знак
  99. }
  100. }
  101. }
  102. return matrix;
  103. }
  104. public Matrix Transpose() // транспонирование матрицы
  105. {
  106. Matrix ret = new Matrix(CountColumn, CountRow, false);
  107. for (int i = 0; i < ret.CountRow; i++)
  108. for (int j = 0; j < ret.CountColumn; j++)
  109. {
  110. ret[i, j] = this[j, i]; // просто меням строку со столбцом
  111. }
  112. return ret;
  113. }
  114.  
  115. public float Determinant() // вычисление определителя
  116. {
  117. if (this.CountRow == 1)// простейший случай для 1*1
  118. return this[0, 0];
  119. if (this.CountRow == 2) // простейший случай для 2*2
  120. {
  121. return this[0, 0] * this[1, 1] - this[0, 1] * this[1, 0];
  122. }
  123. float sign = 1, result = 0;
  124. for (int i = 0; i < CountColumn; i++)
  125. {
  126. Matrix minor = GetMinor(this, i);
  127. result += sign * this[0, i] * minor.Determinant();
  128. sign = -sign;
  129. }
  130. return result;
  131. }
  132. private Matrix GetMinor(Matrix matrix, int n)// получение минора по определению
  133. {
  134. Matrix result = new Matrix(matrix.CountRow - 1, matrix.CountRow - 1); // создаем матрицу с (row-1) * (column-1)
  135. for (int i = 1; i < matrix.CountRow; i++)
  136. {
  137. for (int j = 0, col = 0; j < matrix.CountColumn; j++)
  138. {
  139. if (j == n)
  140. continue;
  141. result[i - 1, col] = matrix[i, j];
  142. col++;
  143. }// копируем элементы
  144. }
  145. return result;
  146. }
  147. public static Matrix operator *(Matrix x1, Matrix x2) // произведение матриц по определению, для проверки обратной матрицы
  148. {
  149. if (x1.CountColumn != x2.CountRow) throw new ArgumentException("Число столбцов матрицы А не равно числу строк матрицы В.");
  150. Matrix ret = new Matrix(x1.CountRow, x2.CountColumn, false);
  151. for (int i = 0; i < x1.CountRow; i++)
  152. for (int j = 0; j < x2.CountColumn; j++)
  153. {
  154. ret[i, j] = 0;
  155. for (int k = 0; k < x2.CountRow; k++)
  156. ret[i, j] += x1[i, k] * x2[k, j];
  157. }
  158. return ret;
  159. }
  160. public Matrix Exclude(int row, int column) // получить матрицу без строки row и столбца column
  161. {
  162. if (row > CountRow || column > CountColumn) throw new IndexOutOfRangeException("Строка или столбец не принадлежат матрице.");
  163. Matrix ret = new Matrix(CountRow - 1, CountColumn - 1, false);
  164. ret.matrix = (float[,])this.matrix.Clone();
  165. int offsetX = 0;
  166. for (int i = 0; i < CountRow; i++)
  167. {
  168. int offsetY = 0;
  169. if (i == row) { offsetX++; continue; }
  170. for (int t = 0; t < CountColumn; t++)
  171. {
  172. if (t == column) { offsetY++; continue; }
  173. ret[i - offsetX, t - offsetY] = this[i, t];
  174. }
  175. }
  176. return ret;
  177. }
  178. public override string ToString() // текстовый вид матрицы для вывода
  179. {
  180. StringBuilder ret = new StringBuilder();
  181. if (matrix == null) return ret.ToString();
  182. for (int i = 0; i < CountRow; i++)
  183. {
  184. for (int t = 0; t < CountColumn; t++)
  185. {
  186. ret.Append(Math.Round(matrix[i, t], 3));
  187. ret.Append("\t");
  188. }
  189. ret.Append("\n");
  190. }
  191. return ret.ToString();
  192. }
  193. void generator(int x, int y, int startGen) // для генерации случайного массива
  194. {
  195. matrix = new float[x, y];
  196. Random rnd = new Random(startGen);
  197. for (int i = 0; i < x * y; i++)
  198. {
  199. int X = i / y;
  200. int Y = i - y * X;
  201. matrix[X, Y] = rnd.Next(-10, 10);
  202. }
  203. }
  204. }
  205. }

Решение задачи: «Does not contain a static 'Main' method suitable for an entry poin»

textual
Листинг программы
  1. namespace ConsoleApplication7
  2. {
  3.     class Program
  4.     {
  5.         static void Main(string[] args)
  6.         {
  7.             //  Отсюда начнет работу твоя программа.
  8.             Matrix matrix1 = new Matrix();  //  создаем ЭКЗЕМПЛЯР класса.
  9.  
  10.             //  Работаем.
  11.         }
  12.     }
  13.    
  14.     //  Это класс. Он сам по себе не исполняется. Чтобы он заработал, нужно создать его экземпляр.
  15.     public class Matrix
  16.     {
  17.         public float[,] matrix = null; // хранение данных
  18.  
  19.         public int CountColumn { get; private set; } // количество столбцов
  20.         public int CountRow { get; private set; } // количество строк
  21. //   и так далее

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


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

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

10   голосов , оценка 3.3 из 5

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

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

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