using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace WpfApp1 { /// /// Логика взаимодействия для Page3.xaml /// public partial class Page3 : Page { public Page3() { InitializeComponent(); } private void RunExperiments_Click(object sender, RoutedEventArgs e) { if (double.TryParse(ParamATextBox.Text, out double a) && double.TryParse(ParamCTextBox.Text, out double c) && double.TryParse(ParamBTextBox.Text, out double b) && double.TryParse(ParamKTextBox.Text, out double k)) { double maxK = FindMaxK(a, c); double maxA = FindMaxA(c, k); double maxKModified = FindMaxKModified(a, c, b); ResultsTextBox.Text = $"Эксперимент 1: Наибольшее значение коэффициента вылова k: {maxK}\n" + $"Эксперимент 2: Наибольшее значение параметра a: {maxA}\n" + $"Модификация 1: Наибольшее значение коэффициента вылова k \n" + $"В модифицированной модели: {maxKModified}"; } else { MessageBox.Show("Пожалуйста, введите числовые значения для всех параметров.", "Ошибка ввода!", MessageBoxButton.OK, MessageBoxImage.Error); } } private double FindMaxK(double a, double c) { double k = 0; while (true) { double nextPopulation = c + a * c - k * c; if (nextPopulation <= 0) break; k++; } return k - 1; } private double FindMaxA(double c, double k) { double a = 0; while (true) { double nextPopulation = c + a * c - k * c; if (nextPopulation <= 0) break; a++; } return a - 1; } private double FindMaxKModified(double a, double c, double b) { double k = 0; while (true) { double nextPopulation = c + a * c - (k + b) * c; if (nextPopulation <= 0) break; k++; } return k - 1; } private void Button_Click_1(object sender, RoutedEventArgs e) { ParamATextBox.Text = string.Empty; ParamCTextBox.Text= string.Empty; ParamBTextBox.Text= string.Empty; ParamKTextBox.Text= string.Empty; ResultsTextBox.Text= string.Empty; } } }