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
Помогите сделать проект, ибо я уже пошел за валидолом
Листинг программы
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication4
- {
- public class Matrix
- {
- public float[,] matrix = null; // хранение данных
- public int CountColumn { get; private set; } // количество столбцов
- public int CountRow { get; private set; } // количество строк
- public Matrix(int x = 1, int y = 1, bool autoGeneration = true, int startGen = 1) // конструктор с параметрами
- {
- if (autoGeneration) generator(x, y, startGen);
- else
- matrix = new float[x, y];
- CountColumn = y;
- CountRow = x;
- }
- public float this[int x, int y] // получить элемент по индексам
- {
- get { return matrix[x, y]; }
- set { matrix[x, y] = value; }
- }
- public static Matrix operator +(Matrix x1, Matrix x2) // для сложения матриц
- {
- if (x1.CountRow != x2.CountRow || x1.CountColumn != x2.CountColumn) throw new ArgumentException("Несоответствующие матрицы");
- Matrix ret = new Matrix(x1.CountRow, x1.CountColumn, false); // новая матрица
- for (int i = 0; i < x1.CountRow; i++)
- for (int j = 0; j < x1.CountColumn; j++)
- {
- ret[i, j] = x1[i, j] + x2[i, j]; // сложение
- }
- return ret;
- }
- public static Matrix operator +(Matrix x1, int x2) // сложения матрицы и числа
- {
- Matrix ret = new Matrix(x1.CountRow, x1.CountColumn, false);
- for (int i = 0; i < x1.CountRow; i++)
- for (int j = 0; j < x1.CountColumn; j++)
- {
- ret[i, j] = x1[i, j] + x2;
- }
- return ret;
- }
- public static Matrix operator -(Matrix x1, Matrix x2) // для вычитания матриц
- {
- if (x1.CountRow != x2.CountRow || x1.CountColumn != x2.CountColumn) throw new ArgumentException("Несоответствующие матрицы");
- Matrix ret = new Matrix(x1.CountRow, x1.CountColumn, false);
- for (int i = 0; i < x1.CountRow; i++)
- for (int j = 0; j < x1.CountColumn; j++)
- {
- ret[i, j] = x1[i, j] - x2[i, j]; // вычитаем из каждого элемента соответствующий
- }
- return ret;
- }
- public static Matrix operator -(Matrix x1, int x2) // вычитание числа из матрицы
- {
- Matrix ret = new Matrix(x1.CountRow, x1.CountColumn, false);
- for (int i = 0; i < x1.CountRow; i++)
- for (int j = 0; j < x1.CountColumn; j++)
- {
- ret[i, j] = x1[i, j] - x2; // вычитаем из каждого числа
- }
- return ret;
- }
- public static bool operator ==(Matrix x1, Matrix x2) // оператор на равенство
- {
- if (x1.CountColumn != x2.CountColumn || x1.CountRow != x2.CountRow)
- return false;
- for (int i = 0; i < x1.CountRow; i++)
- for (int j = 0; j < x1.CountColumn; j++)
- {
- if (x1[i, j] != x2[i, j]) // сравниваем каждый элемент
- return false;
- }
- return true;
- }
- public static bool operator !=(Matrix x1, Matrix x2)// оператор на неравенство
- {
- return (!(x1 == x2));
- }
- public Matrix Inverse() // получение обратной матрицы
- {
- if (CountRow != CountColumn) throw new ArgumentException("Обратная матрица существует только для квадратных, невырожденных, матриц.");
- Matrix matrix = new Matrix(CountRow, CountColumn); //Делаем копию исходной матрицы
- float determinant = this.Determinant(); // вычисление определителя
- if (determinant == 0)
- return matrix; //Если определитель == 0 - матрица вырожденная
- for (int i = 0; i < CountColumn; i++)
- {
- for (int t = 0; t < CountRow; t++)
- {
- Matrix tmp = this.Exclude(i, t); //получаем матрицу без строки i и столбца t
- matrix[t, i] = tmp.Determinant() / determinant;
- if (((i + t) % 2) == 1)
- {
- matrix[t, i] *= -1; // меняем знак
- }
- }
- }
- return matrix;
- }
- public Matrix Transpose() // транспонирование матрицы
- {
- Matrix ret = new Matrix(CountColumn, CountRow, false);
- for (int i = 0; i < ret.CountRow; i++)
- for (int j = 0; j < ret.CountColumn; j++)
- {
- ret[i, j] = this[j, i]; // просто меням строку со столбцом
- }
- return ret;
- }
- public float Determinant() // вычисление определителя
- {
- if (this.CountRow == 1)// простейший случай для 1*1
- return this[0, 0];
- if (this.CountRow == 2) // простейший случай для 2*2
- {
- return this[0, 0] * this[1, 1] - this[0, 1] * this[1, 0];
- }
- float sign = 1, result = 0;
- for (int i = 0; i < CountColumn; i++)
- {
- Matrix minor = GetMinor(this, i);
- result += sign * this[0, i] * minor.Determinant();
- sign = -sign;
- }
- return result;
- }
- private Matrix GetMinor(Matrix matrix, int n)// получение минора по определению
- {
- Matrix result = new Matrix(matrix.CountRow - 1, matrix.CountRow - 1); // создаем матрицу с (row-1) * (column-1)
- for (int i = 1; i < matrix.CountRow; i++)
- {
- for (int j = 0, col = 0; j < matrix.CountColumn; j++)
- {
- if (j == n)
- continue;
- result[i - 1, col] = matrix[i, j];
- col++;
- }// копируем элементы
- }
- return result;
- }
- public static Matrix operator *(Matrix x1, Matrix x2) // произведение матриц по определению, для проверки обратной матрицы
- {
- if (x1.CountColumn != x2.CountRow) throw new ArgumentException("Число столбцов матрицы А не равно числу строк матрицы В.");
- Matrix ret = new Matrix(x1.CountRow, x2.CountColumn, false);
- for (int i = 0; i < x1.CountRow; i++)
- for (int j = 0; j < x2.CountColumn; j++)
- {
- ret[i, j] = 0;
- for (int k = 0; k < x2.CountRow; k++)
- ret[i, j] += x1[i, k] * x2[k, j];
- }
- return ret;
- }
- public Matrix Exclude(int row, int column) // получить матрицу без строки row и столбца column
- {
- if (row > CountRow || column > CountColumn) throw new IndexOutOfRangeException("Строка или столбец не принадлежат матрице.");
- Matrix ret = new Matrix(CountRow - 1, CountColumn - 1, false);
- ret.matrix = (float[,])this.matrix.Clone();
- int offsetX = 0;
- for (int i = 0; i < CountRow; i++)
- {
- int offsetY = 0;
- if (i == row) { offsetX++; continue; }
- for (int t = 0; t < CountColumn; t++)
- {
- if (t == column) { offsetY++; continue; }
- ret[i - offsetX, t - offsetY] = this[i, t];
- }
- }
- return ret;
- }
- public override string ToString() // текстовый вид матрицы для вывода
- {
- StringBuilder ret = new StringBuilder();
- if (matrix == null) return ret.ToString();
- for (int i = 0; i < CountRow; i++)
- {
- for (int t = 0; t < CountColumn; t++)
- {
- ret.Append(Math.Round(matrix[i, t], 3));
- ret.Append("\t");
- }
- ret.Append("\n");
- }
- return ret.ToString();
- }
- void generator(int x, int y, int startGen) // для генерации случайного массива
- {
- matrix = new float[x, y];
- Random rnd = new Random(startGen);
- for (int i = 0; i < x * y; i++)
- {
- int X = i / y;
- int Y = i - y * X;
- matrix[X, Y] = rnd.Next(-10, 10);
- }
- }
- }
- }
Решение задачи: «Does not contain a static 'Main' method suitable for an entry poin»
textual
Листинг программы
- namespace ConsoleApplication7
- {
- class Program
- {
- static void Main(string[] args)
- {
- // Отсюда начнет работу твоя программа.
- Matrix matrix1 = new Matrix(); // создаем ЭКЗЕМПЛЯР класса.
- // Работаем.
- }
- }
- // Это класс. Он сам по себе не исполняется. Чтобы он заработал, нужно создать его экземпляр.
- public class Matrix
- {
- public float[,] matrix = null; // хранение данных
- public int CountColumn { get; private set; } // количество столбцов
- public int CountRow { get; private set; } // количество строк
- // и так далее
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д