using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static double parse(string message) { Console.Write(message); string buf = ""; double y = 1, x = 1; Boolean check; ; do { try { check = true; buf = Console.ReadLine(); x = double.Parse(buf); int ix = (int)x; if ((ix / x != 1 || ix == 0 || x < 0) && message != "") throw new FormatException(); } catch { Console.ForegroundColor = ConsoleColor.Red; Console.Beep(300, 600); Console.WriteLine("Введённые данные неверны, повторите попытку"); Console.ForegroundColor = ConsoleColor.Gray; Console.Write(message); check = false; y++; if (y > 5) { for (int t = 3; t > 0; --t) { Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Программа закроется через {0} с. ", t); System.Threading.Thread.Sleep(1000); } Console.Clear(); Console.ForegroundColor = ConsoleColor.Gray; Environment.Exit(0); } } Console.ForegroundColor = ConsoleColor.Gray; } while (!check && y <= 5); return x; } static void Main(string[] args) { byte strok = (byte)parse("Введите количество строк\nm = "); byte stolb = (byte)parse("Введите количество столбцов\nn = "); double [,] a = new double [strok,stolb]; for(byte i =0;i < strok;++i) for (byte j = 0; j < stolb; ++j) { Console.WriteLine("Введите элемент массива на пересечении {0} строки и {1} столбца", i+1, j+1); a[i, j] = parse(""); } for (int i = 0; i < strok; ++i) { Console.WriteLine("\n"); for (int j = 0; j < stolb; ++j) { Console.Write("{0,7:f2}",a[i, j]); } } for (int i = 0; i < strok; ++i) { int j; for (j = 0; j < stolb && a[i,j]>=0; ++j) {} if (j == stolb && a[i, j - 1] >= 0) { Console.WriteLine("\n\nВ строке {0} нет отрицателных элементов", i+1); } else { double summelem = 0; for (j = 0; j < stolb; ++j) { summelem+=a[i,j]; } Console.WriteLine("\nСумма элементов {0} сроки равна {1}", i + 1, summelem); } } double max,min; int imin, jmin, imax=0, jmax=0; bool check = false,check2 = false; for ( int i2 = 0,j = 0; i2 < strok; ++i2) { int i; min = a[i2,j]; imin = i2; jmin = j; for (j = 1; j < stolb; ++j) { if (a[i2, j] < min) { min = a[i2, j]; jmin = j; } } max = a[imin,jmin]; imax = imin; jmax = jmin; for (j = jmin, i = 0; i < strok; ++i) if (a[i,j]>max) { max = a[i, j]; imax = i; } if (imin == imax ) { for (i = imax, j = 0; j < strok - 1; ++j) if (a[i, j] != a[i, j + 1]) check2 = true; } if (imin == imax ) { for (j = jmax, i = 0; i < stolb - 1; ++i) if (a[i, j] != a[i+1, j ]) check2 = true; } if (imin == imax && check2) { Console.WriteLine("\nCедловая точка матрицы находится в {0} строке, в {1} столбце\n", imin + 1, jmax + 1); check = true; } else { check =false; } } if (!check) { Console.WriteLine("\nВ матрице нет седловых точек\n"); } } } }