Просмотр исходного кода

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

Вадим Королёв 2 лет назад
Родитель
Сommit
13543b72a0

+ 25 - 0
4 Cyclic algorythms/FormCycles.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}") = "FormCycles", "FormCycles\FormCycles.csproj", "{FC21D48A-1A3F-4C5E-B70D-2D90634266DD}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{FC21D48A-1A3F-4C5E-B70D-2D90634266DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{FC21D48A-1A3F-4C5E-B70D-2D90634266DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{FC21D48A-1A3F-4C5E-B70D-2D90634266DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{FC21D48A-1A3F-4C5E-B70D-2D90634266DD}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {84F8F85A-EA42-4DB8-A7BA-E6BCD1A14340}
+	EndGlobalSection
+EndGlobal

+ 172 - 0
4 Cyclic algorythms/FormCycles/CyclesMain.Designer.cs

@@ -0,0 +1,172 @@
+
+namespace FormCycles
+{
+    partial class Main
+    {
+        /// <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.lblInputX0 = new System.Windows.Forms.Label();
+            this.lblInputXk = new System.Windows.Forms.Label();
+            this.lblInputDx = new System.Windows.Forms.Label();
+            this.lblInputB = new System.Windows.Forms.Label();
+            this.tbInputX0 = new System.Windows.Forms.TextBox();
+            this.tbInputXk = new System.Windows.Forms.TextBox();
+            this.tbInputDx = new System.Windows.Forms.TextBox();
+            this.tbInputB = new System.Windows.Forms.TextBox();
+            this.tbOutput = new System.Windows.Forms.TextBox();
+            this.btnCalculate = new System.Windows.Forms.Button();
+            this.SuspendLayout();
+            // 
+            // lblInputX0
+            // 
+            this.lblInputX0.AutoSize = true;
+            this.lblInputX0.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+            this.lblInputX0.Location = new System.Drawing.Point(13, 9);
+            this.lblInputX0.Name = "lblInputX0";
+            this.lblInputX0.Size = new System.Drawing.Size(43, 21);
+            this.lblInputX0.TabIndex = 0;
+            this.lblInputX0.Text = "X0 =";
+            // 
+            // lblInputXk
+            // 
+            this.lblInputXk.AutoSize = true;
+            this.lblInputXk.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+            this.lblInputXk.Location = new System.Drawing.Point(13, 43);
+            this.lblInputXk.Name = "lblInputXk";
+            this.lblInputXk.Size = new System.Drawing.Size(42, 21);
+            this.lblInputXk.TabIndex = 1;
+            this.lblInputXk.Text = "Xk =";
+            // 
+            // lblInputDx
+            // 
+            this.lblInputDx.AutoSize = true;
+            this.lblInputDx.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+            this.lblInputDx.Location = new System.Drawing.Point(12, 78);
+            this.lblInputDx.Name = "lblInputDx";
+            this.lblInputDx.Size = new System.Drawing.Size(43, 21);
+            this.lblInputDx.TabIndex = 2;
+            this.lblInputDx.Text = "Dx =";
+            // 
+            // lblInputB
+            // 
+            this.lblInputB.AutoSize = true;
+            this.lblInputB.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+            this.lblInputB.Location = new System.Drawing.Point(12, 113);
+            this.lblInputB.Name = "lblInputB";
+            this.lblInputB.Size = new System.Drawing.Size(34, 21);
+            this.lblInputB.TabIndex = 3;
+            this.lblInputB.Text = "B =";
+            // 
+            // tbInputX0
+            // 
+            this.tbInputX0.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+            this.tbInputX0.Location = new System.Drawing.Point(61, 6);
+            this.tbInputX0.Name = "tbInputX0";
+            this.tbInputX0.Size = new System.Drawing.Size(138, 29);
+            this.tbInputX0.TabIndex = 4;
+            // 
+            // tbInputXk
+            // 
+            this.tbInputXk.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+            this.tbInputXk.Location = new System.Drawing.Point(61, 40);
+            this.tbInputXk.Name = "tbInputXk";
+            this.tbInputXk.Size = new System.Drawing.Size(138, 29);
+            this.tbInputXk.TabIndex = 5;
+            // 
+            // tbInputDx
+            // 
+            this.tbInputDx.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+            this.tbInputDx.Location = new System.Drawing.Point(61, 75);
+            this.tbInputDx.Name = "tbInputDx";
+            this.tbInputDx.Size = new System.Drawing.Size(138, 29);
+            this.tbInputDx.TabIndex = 6;
+            // 
+            // tbInputB
+            // 
+            this.tbInputB.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+            this.tbInputB.Location = new System.Drawing.Point(61, 110);
+            this.tbInputB.Name = "tbInputB";
+            this.tbInputB.Size = new System.Drawing.Size(138, 29);
+            this.tbInputB.TabIndex = 7;
+            // 
+            // tbOutput
+            // 
+            this.tbOutput.Location = new System.Drawing.Point(12, 155);
+            this.tbOutput.Multiline = true;
+            this.tbOutput.Name = "tbOutput";
+            this.tbOutput.ScrollBars = System.Windows.Forms.ScrollBars.Both;
+            this.tbOutput.Size = new System.Drawing.Size(401, 152);
+            this.tbOutput.TabIndex = 8;
+            // 
+            // btnCalculate
+            // 
+            this.btnCalculate.Location = new System.Drawing.Point(149, 322);
+            this.btnCalculate.Name = "btnCalculate";
+            this.btnCalculate.Size = new System.Drawing.Size(127, 36);
+            this.btnCalculate.TabIndex = 9;
+            this.btnCalculate.Text = "Вычислить";
+            this.btnCalculate.UseVisualStyleBackColor = true;
+            this.btnCalculate.Click += new System.EventHandler(this.btnCalculateClick);
+            // 
+            // Main
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(425, 370);
+            this.Controls.Add(this.btnCalculate);
+            this.Controls.Add(this.tbOutput);
+            this.Controls.Add(this.tbInputB);
+            this.Controls.Add(this.tbInputDx);
+            this.Controls.Add(this.tbInputXk);
+            this.Controls.Add(this.tbInputX0);
+            this.Controls.Add(this.lblInputB);
+            this.Controls.Add(this.lblInputDx);
+            this.Controls.Add(this.lblInputXk);
+            this.Controls.Add(this.lblInputX0);
+            this.Name = "Main";
+            this.Text = "Циклы";
+            this.Load += new System.EventHandler(this.Main_Load);
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.Label lblInputX0;
+        private System.Windows.Forms.Label lblInputXk;
+        private System.Windows.Forms.Label lblInputDx;
+        private System.Windows.Forms.Label lblInputB;
+        private System.Windows.Forms.TextBox tbInputX0;
+        private System.Windows.Forms.TextBox tbInputXk;
+        private System.Windows.Forms.TextBox tbInputDx;
+        private System.Windows.Forms.TextBox tbInputB;
+        private System.Windows.Forms.TextBox tbOutput;
+        private System.Windows.Forms.Button btnCalculate;
+    }
+}
+

+ 66 - 0
4 Cyclic algorythms/FormCycles/CyclesMain.cs

@@ -0,0 +1,66 @@
+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 FormCycles
+{
+    public partial class Main : Form
+    {
+        public Main()
+        {
+            InitializeComponent();
+        }
+
+        private void Main_Load(object sender, EventArgs e)
+        {
+            // Центрируем кнопку вычисления ответа
+            // Получаем ширину кнопки и формы
+            int ButtonWidth = btnCalculate.Size.Width;
+            int FormWidth = this.Size.Width;
+            // Переопределяем позицию
+            btnCalculate.Location = new Point(new Size((FormWidth - ButtonWidth) / 2, 322));
+        }
+
+		/// <summary>
+		/// Вычисление ответа по нажатию на кнопку
+		/// </summary>
+        private void btnCalculateClick(object sender, EventArgs e)
+        {
+            // Считываем значения, проверяем правильность
+            double X0, Xk, Dx, B;
+            try
+            {
+                X0 = double.Parse(tbInputX0.Text);
+                Xk = double.Parse(tbInputXk.Text);
+                Dx = double.Parse(tbInputDx.Text);
+                B = double.Parse(tbInputB.Text);
+            }
+            catch (FormatException)
+            {
+                MessageBox.Show("Убедитесь, что во всех полях указаны числа в правильном формате!");
+                return;
+            }
+
+            // Перезаписываем текст поля ответа
+            tbOutput.Text = $"Работу выполнил ст. Королёв В. С.{Environment.NewLine}";
+
+            // Выполняем цикл, используя данные значения
+            double x = X0;
+            double y;
+            while(true)
+            {
+                if (x > Xk) break;
+                
+                y = 9 * (Math.Pow(x,3) + Math.Pow(B, 3) * Math.Tan(x));
+                tbOutput.Text += $"x={x}; y={y}{Environment.NewLine}";
+                x += Dx;
+            }
+        }
+    }
+}

+ 60 - 0
4 Cyclic algorythms/FormCycles/CyclesMain.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>

+ 9 - 0
4 Cyclic algorythms/FormCycles/FormCycles.csproj

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

+ 23 - 0
4 Cyclic algorythms/FormCycles/Program.cs

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