Определить индексы всех седловых точек задаваемого массива. Получился такой код, но что-то не так не могу найти ошибку, пожалуйста помогите.
| Код | using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace sedlovuy { class Program { static void Main(string[] args) { int h = -100; int max = 0; int l = 100; int min = 0; int MAX = 0; int MIN = 0; int Q=0; int W=0; int E=0; int R=0; Console.Write("vvedite kolichestvo strok:"); int n = int.Parse(Console.ReadLine());
Console.Write("vvedite kolichestvo stolbcov:"); int k = int.Parse(Console.ReadLine()); int[,] A = new int[n,k]; for (int i = 1; i < n+1; i++) { for (int j = 0; j < k; j++) { Console.Write(" Vvedite A({0},{1}):", i, j); int g=int.Parse(Console.ReadLine()); if (g > h) { max = g; Q=j; } h = g; if (g < l) { min = g; W=j; } l = g;
} h = -100; l = 100; if (max > h) { MAX = max; E=i; h = max; }
if (min < l) { MIN = min; R=i; l = min; }
} if (MAX == min) { Console.WriteLine("sedlovaya tochka A({0},{0})", E, W); }
if (MIN == max) { Console.WriteLine("sedlovaya tochka A({0},{0})", R, Q); } Console.ReadLine(); } } }
|
|