Przeglądaj źródła

Добавлена 3 лабораторная

user 2 lat temu
rodzic
commit
84f1e01512

+ 25 - 0
3 Branching algorythms/RadioCalculator.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.32802.440
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RadioCalculator", "RadioCalculator\RadioCalculator.csproj", "{E211EF5F-26FD-4FEA-AEAB-3E45171D7605}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{E211EF5F-26FD-4FEA-AEAB-3E45171D7605}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{E211EF5F-26FD-4FEA-AEAB-3E45171D7605}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{E211EF5F-26FD-4FEA-AEAB-3E45171D7605}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{E211EF5F-26FD-4FEA-AEAB-3E45171D7605}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {5D764D29-6AE0-4E8A-B6BD-EB475211454D}
+	EndGlobalSection
+EndGlobal

+ 207 - 0
3 Branching algorythms/RadioCalculator/CalculatorMain.Designer.cs

@@ -0,0 +1,207 @@
+
+namespace RadioCalculator
+{
+    partial class CalculatorMain
+    {
+        /// <summary>
+        ///  Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        ///  Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        ///  Required method for Designer support - do not modify
+        ///  the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.grbSelectFunction = new System.Windows.Forms.GroupBox();
+            this.rbFunctionEPow = new System.Windows.Forms.RadioButton();
+            this.rbFunctionPow2 = new System.Windows.Forms.RadioButton();
+            this.rbFunctionSh = new System.Windows.Forms.RadioButton();
+            this.lblX = new System.Windows.Forms.Label();
+            this.lblY = new System.Windows.Forms.Label();
+            this.lblZ = new System.Windows.Forms.Label();
+            this.tbInputX = new System.Windows.Forms.TextBox();
+            this.tbInputY = new System.Windows.Forms.TextBox();
+            this.tbInputZ = new System.Windows.Forms.TextBox();
+            this.lblAnswer = new System.Windows.Forms.Label();
+            this.btnCalculate = new System.Windows.Forms.Button();
+            this.grbSelectFunction.SuspendLayout();
+            this.SuspendLayout();
+            // 
+            // grbSelectFunction
+            // 
+            this.grbSelectFunction.Controls.Add(this.rbFunctionEPow);
+            this.grbSelectFunction.Controls.Add(this.rbFunctionPow2);
+            this.grbSelectFunction.Controls.Add(this.rbFunctionSh);
+            this.grbSelectFunction.Location = new System.Drawing.Point(12, 12);
+            this.grbSelectFunction.Name = "grbSelectFunction";
+            this.grbSelectFunction.Size = new System.Drawing.Size(116, 99);
+            this.grbSelectFunction.TabIndex = 0;
+            this.grbSelectFunction.TabStop = false;
+            this.grbSelectFunction.Text = "Функция";
+            // 
+            // rbFunctionEPow
+            // 
+            this.rbFunctionEPow.AutoSize = true;
+            this.rbFunctionEPow.Location = new System.Drawing.Point(6, 72);
+            this.rbFunctionEPow.Name = "rbFunctionEPow";
+            this.rbFunctionEPow.Size = new System.Drawing.Size(35, 19);
+            this.rbFunctionEPow.TabIndex = 2;
+            this.rbFunctionEPow.TabStop = true;
+            this.rbFunctionEPow.Text = "e˟";
+            this.rbFunctionEPow.UseVisualStyleBackColor = true;
+            // 
+            // rbFunctionPow2
+            // 
+            this.rbFunctionPow2.AutoSize = true;
+            this.rbFunctionPow2.Location = new System.Drawing.Point(6, 47);
+            this.rbFunctionPow2.Name = "rbFunctionPow2";
+            this.rbFunctionPow2.Size = new System.Drawing.Size(35, 19);
+            this.rbFunctionPow2.TabIndex = 1;
+            this.rbFunctionPow2.TabStop = true;
+            this.rbFunctionPow2.Text = "x²";
+            this.rbFunctionPow2.UseMnemonic = false;
+            this.rbFunctionPow2.UseVisualStyleBackColor = true;
+            // 
+            // rbFunctionSh
+            // 
+            this.rbFunctionSh.AutoSize = true;
+            this.rbFunctionSh.Location = new System.Drawing.Point(6, 22);
+            this.rbFunctionSh.Name = "rbFunctionSh";
+            this.rbFunctionSh.Size = new System.Drawing.Size(51, 19);
+            this.rbFunctionSh.TabIndex = 0;
+            this.rbFunctionSh.TabStop = true;
+            this.rbFunctionSh.Text = "sh(x)";
+            this.rbFunctionSh.UseVisualStyleBackColor = true;
+            // 
+            // lblX
+            // 
+            this.lblX.AutoSize = true;
+            this.lblX.Font = new System.Drawing.Font("Segoe UI Semibold", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
+            this.lblX.Location = new System.Drawing.Point(162, 12);
+            this.lblX.Name = "lblX";
+            this.lblX.Size = new System.Drawing.Size(26, 32);
+            this.lblX.TabIndex = 1;
+            this.lblX.Text = "x";
+            // 
+            // lblY
+            // 
+            this.lblY.AutoSize = true;
+            this.lblY.Font = new System.Drawing.Font("Segoe UI Semibold", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
+            this.lblY.Location = new System.Drawing.Point(162, 59);
+            this.lblY.Name = "lblY";
+            this.lblY.Size = new System.Drawing.Size(26, 32);
+            this.lblY.TabIndex = 2;
+            this.lblY.Text = "y";
+            // 
+            // lblZ
+            // 
+            this.lblZ.AutoSize = true;
+            this.lblZ.Font = new System.Drawing.Font("Segoe UI Semibold", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
+            this.lblZ.Location = new System.Drawing.Point(162, 112);
+            this.lblZ.Name = "lblZ";
+            this.lblZ.Size = new System.Drawing.Size(25, 32);
+            this.lblZ.TabIndex = 3;
+            this.lblZ.Text = "z";
+            // 
+            // tbInputX
+            // 
+            this.tbInputX.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+            this.tbInputX.Location = new System.Drawing.Point(208, 18);
+            this.tbInputX.Name = "tbInputX";
+            this.tbInputX.Size = new System.Drawing.Size(199, 29);
+            this.tbInputX.TabIndex = 4;
+            // 
+            // tbInputY
+            // 
+            this.tbInputY.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+            this.tbInputY.Location = new System.Drawing.Point(208, 65);
+            this.tbInputY.Name = "tbInputY";
+            this.tbInputY.Size = new System.Drawing.Size(199, 29);
+            this.tbInputY.TabIndex = 5;
+            // 
+            // tbInputZ
+            // 
+            this.tbInputZ.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+            this.tbInputZ.Location = new System.Drawing.Point(208, 118);
+            this.tbInputZ.Name = "tbInputZ";
+            this.tbInputZ.Size = new System.Drawing.Size(199, 29);
+            this.tbInputZ.TabIndex = 6;
+            // 
+            // lblAnswer
+            // 
+            this.lblAnswer.AutoSize = true;
+            this.lblAnswer.Font = new System.Drawing.Font("Segoe UI Semibold", 36F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
+            this.lblAnswer.Location = new System.Drawing.Point(12, 226);
+            this.lblAnswer.Name = "lblAnswer";
+            this.lblAnswer.Size = new System.Drawing.Size(374, 65);
+            this.lblAnswer.TabIndex = 7;
+            this.lblAnswer.Text = "Область ответа";
+            // 
+            // btnCalculate
+            // 
+            this.btnCalculate.Location = new System.Drawing.Point(208, 174);
+            this.btnCalculate.Name = "btnCalculate";
+            this.btnCalculate.Size = new System.Drawing.Size(199, 34);
+            this.btnCalculate.TabIndex = 8;
+            this.btnCalculate.Text = "Пуск!";
+            this.btnCalculate.UseVisualStyleBackColor = true;
+            this.btnCalculate.Click += new System.EventHandler(this.btnCalculate_Click);
+            // 
+            // CalculatorMain
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(479, 313);
+            this.Controls.Add(this.btnCalculate);
+            this.Controls.Add(this.lblAnswer);
+            this.Controls.Add(this.tbInputZ);
+            this.Controls.Add(this.tbInputY);
+            this.Controls.Add(this.tbInputX);
+            this.Controls.Add(this.lblZ);
+            this.Controls.Add(this.lblY);
+            this.Controls.Add(this.lblX);
+            this.Controls.Add(this.grbSelectFunction);
+            this.Name = "CalculatorMain";
+            this.Text = "Калькулятор";
+            this.Load += new System.EventHandler(this.CalcMainLoad);
+            this.grbSelectFunction.ResumeLayout(false);
+            this.grbSelectFunction.PerformLayout();
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.GroupBox grbSelectFunction;
+        private System.Windows.Forms.RadioButton rbFunctionEPow;
+        private System.Windows.Forms.RadioButton rbFunctionPow2;
+        private System.Windows.Forms.RadioButton rbFunctionSh;
+        private System.Windows.Forms.Label lblX;
+        private System.Windows.Forms.Label lblY;
+        private System.Windows.Forms.Label lblZ;
+        private System.Windows.Forms.TextBox tbInputX;
+        private System.Windows.Forms.TextBox tbInputY;
+        private System.Windows.Forms.TextBox tbInputZ;
+        private System.Windows.Forms.Label lblAnswer;
+        private System.Windows.Forms.Button btnCalculate;
+    }
+}
+

+ 71 - 0
3 Branching algorythms/RadioCalculator/CalculatorMain.cs

@@ -0,0 +1,71 @@
+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;
+
+namespace RadioCalculator
+{
+    public partial class CalculatorMain : Form
+    {
+        public CalculatorMain()
+        {
+            InitializeComponent();
+        }
+
+        private void CalcMainLoad(object sender, EventArgs e)
+        {
+            lblAnswer.Visible = false;
+        }
+
+        private void btnCalculate_Click(object sender, EventArgs e)
+        {
+            // Считываем значения, проверяем правильность
+            float x, y, z, Output;
+            try
+            {
+                x = float.Parse(tbInputX.Text);
+                y = float.Parse(tbInputY.Text);
+                z = float.Parse(tbInputZ.Text);
+            }
+            catch (FormatException)
+            {
+                MessageBox.Show("Убедитесь, что во всех полях указаны числа в правильном формате!");
+                return;
+            }
+
+            // Вычисляем ответ
+            // Значение функции f(x)
+            float FunctionOutput;
+            try
+            {
+                if (rbFunctionSh.Checked)
+                {
+                    FunctionOutput = MathF.Sinh(x);
+                }
+                else if (rbFunctionPow2.Checked)
+                {
+                    FunctionOutput = (float)Math.Pow(x, 2);
+                }
+                else
+                {
+                    FunctionOutput = (float)Math.Pow(Math.E, x);
+                }
+                // Значение выражения
+                Output = Math.Min(FunctionOutput + y, y - z) / Math.Max(FunctionOutput, y);
+            } catch (Exception ex)
+            {
+                MessageBox.Show($"Возникла ошибка при вычислении выражения! ({ex.Message})");
+                return;
+            }
+            
+            // Записываем ответ в надпись
+            lblAnswer.Visible = true;
+            lblAnswer.Text = Convert.ToString(Output);
+        }
+    }
+}

+ 60 - 0
3 Branching algorythms/RadioCalculator/CalculatorMain.resx

@@ -0,0 +1,60 @@
+<root>
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 23 - 0
3 Branching algorythms/RadioCalculator/Program.cs

@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace RadioCalculator
+{
+    static class Program
+    {
+        /// <summary>
+        ///  The main entry point for the application.
+        /// </summary>
+        [STAThread]
+        static void Main()
+        {
+            Application.SetHighDpiMode(HighDpiMode.SystemAware);
+            Application.EnableVisualStyles();
+            Application.SetCompatibleTextRenderingDefault(false);
+            Application.Run(new CalculatorMain());
+        }
+    }
+}

+ 9 - 0
3 Branching algorythms/RadioCalculator/RadioCalculator.csproj

@@ -0,0 +1,9 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>WinExe</OutputType>
+    <TargetFramework>net5.0-windows</TargetFramework>
+    <UseWindowsForms>true</UseWindowsForms>
+  </PropertyGroup>
+
+</Project>