Browse Source

Загрузить файлы ''

21IS15 2 years ago
parent
commit
ae463e5748
1 changed files with 57 additions and 0 deletions
  1. 57 0
      Form1_Lab4.cs

+ 57 - 0
Form1_Lab4.cs

@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using System.Xml.Resolvers;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement;
+
+namespace Ul_4
+{
+    public partial class Form1 : Form
+    {
+        public Form1()
+        {
+            InitializeComponent();
+        }
+
+        private void Form1_Load(object sender, EventArgs e)
+        {
+
+        }
+
+        private double CalculateFunction(double x, double b)
+        {
+            double result = Math.Pow(10, -3) * Math.Pow(Math.Abs(x), 5.0 / 2.0) + Math.Log(Math.Abs(x + b));
+            return result;
+        }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+            double x0 = 1.75;
+            double xk = -2.5;
+            double dx = -0.25;
+            double b = 35.4;
+
+            int arrayLength = Convert.ToInt32(Math.Abs((xk - x0) / dx)) + 1;
+            double[] results = new double[arrayLength];
+            int index = 0;
+
+            for (double x = x0; x >= xk; x += dx)
+            {
+                double result = CalculateFunction(x, b);
+                results[index++] = result;
+            }
+
+            // вывод результатов на форму
+            for (int i = 0; i < arrayLength; i++)
+            {
+                listBox1.Items.Add($"y = {x0 - i * dx:F2} - f(x) = {results[i]:F4}");
+            }
+        }
+    }
+}