Эх сурвалжийг харах

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

user 2 жил өмнө
parent
commit
80ead90c0b

+ 151 - 0
2 Linear algorythms/MainForm.Designer.cs

@@ -0,0 +1,151 @@
+
+namespace calculator
+{
+    partial class MainForm
+    {
+        /// <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.tbInputX = new System.Windows.Forms.TextBox();
+            this.tbInputY = new System.Windows.Forms.TextBox();
+            this.tbInputZ = new System.Windows.Forms.TextBox();
+            this.lblX = new System.Windows.Forms.Label();
+            this.lblY = new System.Windows.Forms.Label();
+            this.lblZ = new System.Windows.Forms.Label();
+            this.lblAnswer = new System.Windows.Forms.Label();
+            this.btnCalculate = new System.Windows.Forms.Button();
+            this.SuspendLayout();
+            // 
+            // tbInputX
+            // 
+            this.tbInputX.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+            this.tbInputX.Location = new System.Drawing.Point(55, 84);
+            this.tbInputX.Name = "tbInputX";
+            this.tbInputX.Size = new System.Drawing.Size(177, 35);
+            this.tbInputX.TabIndex = 0;
+            // 
+            // tbInputY
+            // 
+            this.tbInputY.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+            this.tbInputY.Location = new System.Drawing.Point(284, 84);
+            this.tbInputY.Name = "tbInputY";
+            this.tbInputY.Size = new System.Drawing.Size(177, 35);
+            this.tbInputY.TabIndex = 1;
+            // 
+            // tbInputZ
+            // 
+            this.tbInputZ.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+            this.tbInputZ.Location = new System.Drawing.Point(543, 84);
+            this.tbInputZ.Name = "tbInputZ";
+            this.tbInputZ.Size = new System.Drawing.Size(177, 35);
+            this.tbInputZ.TabIndex = 2;
+            // 
+            // lblX
+            // 
+            this.lblX.AutoSize = true;
+            this.lblX.Font = new System.Drawing.Font("Segoe UI Semibold", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
+            this.lblX.Location = new System.Drawing.Point(109, 36);
+            this.lblX.Name = "lblX";
+            this.lblX.Size = new System.Drawing.Size(40, 45);
+            this.lblX.TabIndex = 3;
+            this.lblX.Text = "X";
+            // 
+            // lblY
+            // 
+            this.lblY.AutoSize = true;
+            this.lblY.Font = new System.Drawing.Font("Segoe UI Semibold", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
+            this.lblY.Location = new System.Drawing.Point(356, 36);
+            this.lblY.Name = "lblY";
+            this.lblY.Size = new System.Drawing.Size(38, 45);
+            this.lblY.TabIndex = 4;
+            this.lblY.Text = "Y";
+            // 
+            // lblZ
+            // 
+            this.lblZ.AutoSize = true;
+            this.lblZ.Font = new System.Drawing.Font("Segoe UI Semibold", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
+            this.lblZ.Location = new System.Drawing.Point(613, 36);
+            this.lblZ.Name = "lblZ";
+            this.lblZ.Size = new System.Drawing.Size(39, 45);
+            this.lblZ.TabIndex = 5;
+            this.lblZ.Text = "Z";
+            // 
+            // 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.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
+            this.lblAnswer.Location = new System.Drawing.Point(36, 453);
+            this.lblAnswer.Name = "lblAnswer";
+            this.lblAnswer.Size = new System.Drawing.Size(374, 65);
+            this.lblAnswer.TabIndex = 6;
+            this.lblAnswer.Text = "Область ответа";
+            // 
+            // btnCalculate
+            // 
+            this.btnCalculate.Font = new System.Drawing.Font("Segoe UI", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+            this.btnCalculate.Location = new System.Drawing.Point(284, 253);
+            this.btnCalculate.Name = "btnCalculate";
+            this.btnCalculate.Size = new System.Drawing.Size(177, 64);
+            this.btnCalculate.TabIndex = 7;
+            this.btnCalculate.Text = "Вычислить!";
+            this.btnCalculate.UseVisualStyleBackColor = true;
+            this.btnCalculate.Click += new System.EventHandler(this.btnCalculate_Click);
+            // 
+            // Main
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(784, 561);
+            this.Controls.Add(this.btnCalculate);
+            this.Controls.Add(this.lblAnswer);
+            this.Controls.Add(this.lblZ);
+            this.Controls.Add(this.lblY);
+            this.Controls.Add(this.lblX);
+            this.Controls.Add(this.tbInputZ);
+            this.Controls.Add(this.tbInputY);
+            this.Controls.Add(this.tbInputX);
+            this.Name = "Main";
+            this.Text = "Калькулятор";
+            this.Load += new System.EventHandler(this.Form1_Load);
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.TextBox tbInputX;
+        private System.Windows.Forms.TextBox tbInputY;
+        private System.Windows.Forms.TextBox tbInputZ;
+        private System.Windows.Forms.Label lblX;
+        private System.Windows.Forms.Label lblY;
+        private System.Windows.Forms.Label lblZ;
+        private System.Windows.Forms.Label lblAnswer;
+        private System.Windows.Forms.Button btnCalculate;
+    }
+}
+

+ 58 - 0
2 Linear algorythms/MainForm.cs

@@ -0,0 +1,58 @@
+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 calculator
+{
+    public partial class MainForm : Form
+    {
+        public MainForm()
+        {
+            InitializeComponent();
+        }
+
+        private void btnCalculate_Click(object sender, EventArgs e)
+        {
+            double x, y, z;
+            // Считываем данные
+            try
+            {
+                x = double.Parse(tbInputX.Text);
+                y = double.Parse(tbInputY.Text);
+                z = double.Parse(tbInputZ.Text);
+            } catch (FormatException)
+            {
+                MessageBox.Show("Убедитесь, что во всех полях указаны числа в правильном формате!");
+                return;
+            }
+
+            // Вычисляем ответ
+            double Output = 0.00d;
+            try
+            {
+                Output += Math.Pow(2, Math.Pow(y, x));
+                Output += Math.Pow(Math.Pow(3, x), y);
+                Output -= (y * (Math.Atan(z) - Math.PI / 6)) / (Math.Abs(x) + 1 / (y * y + 1));
+            } catch (DivideByZeroException)
+            {
+                MessageBox.Show("При вычислении ответа необходимо делить на 0!");
+                return;
+            }
+
+            // Выводим ответ в lblAnswer
+            lblAnswer.Visible = true;
+            lblAnswer.Text = Convert.ToString(Output);
+        }
+
+        private void Form1_Load(object sender, EventArgs e)
+        {
+            lblAnswer.Visible = false;
+        }
+    }
+}

+ 60 - 0
2 Linear algorythms/MainForm.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
2 Linear algorythms/Program.cs

@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace calculator
+{
+    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 MainForm());
+        }
+    }
+}

+ 9 - 0
2 Linear algorythms/calculator.csproj

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

+ 25 - 0
2 Linear algorythms/calculator.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}") = "calculator", "calculator.csproj", "{66C86A56-FC8E-4D22-9759-198B7487DBA7}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{66C86A56-FC8E-4D22-9759-198B7487DBA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{66C86A56-FC8E-4D22-9759-198B7487DBA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{66C86A56-FC8E-4D22-9759-198B7487DBA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{66C86A56-FC8E-4D22-9759-198B7487DBA7}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {E9D40AEE-744D-4EFE-9615-9AB40A546632}
+	EndGlobalSection
+EndGlobal