123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- 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
- {
- /// <summary>
- /// Логика взаимодействия для Page3.xaml
- /// </summary>
- 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;
- }
- }
- }
|