Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace LB4_1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int counter = 0;
- Console.Write("Пожалуйста, введите порядок квадратной матрицы:");
- int por = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Введите все элементы квадратной матрицы по порядку:");
- int[,] matrix = new int[por, por];
- for (int i = 0; i < por; i++)
- for (int j = 0; j < por; j++)
- Console.WriteLine("matrix[{0},{1}] = {2}", j, i, matrix[j, i] = Convert.ToInt32(Console.ReadLine()));
- for (int i = 0; i < Math.Sqrt(matrix.Length); ++i)
- for (int j = i + 1; j < Math.Sqrt(matrix.Length); ++j)
- counter += matrix[i, j] == matrix[j, i] ? 1 : 0;
- Console.WriteLine(counter == Convert.ToInt32(matrix.Length - Math.Sqrt(matrix.Length)) / 2 ? "Матрица является симметричной относительно главной диагонали" : "Матрица не является симметричной относительно главной диагонали");
- Console.Read();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement