From f5843777d352162612b3aadeb91e5514d288193b Mon Sep 17 00:00:00 2001 From: Adelina888 Date: Tue, 25 Jun 2024 22:22:18 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D0=BE=D0=B2=D0=B8=D0=BD?= =?UTF-8?q?=D0=B0=201=20=D0=BF=D1=80=D0=B0=D0=BA=D1=82=D0=B8=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Praktika/Form1.Designer.cs | 324 +++++++++++++++++++++++++++++++++++++ Praktika/Form1.cs | 234 +++++++++++++++++++++++++++ Praktika/Form1.resx | 120 ++++++++++++++ Praktika/Praktika.csproj | 11 ++ Praktika/Praktika.sln | 25 +++ Praktika/Program.cs | 17 ++ 6 files changed, 731 insertions(+) create mode 100644 Praktika/Form1.Designer.cs create mode 100644 Praktika/Form1.cs create mode 100644 Praktika/Form1.resx create mode 100644 Praktika/Praktika.csproj create mode 100644 Praktika/Praktika.sln create mode 100644 Praktika/Program.cs diff --git a/Praktika/Form1.Designer.cs b/Praktika/Form1.Designer.cs new file mode 100644 index 0000000..888357f --- /dev/null +++ b/Praktika/Form1.Designer.cs @@ -0,0 +1,324 @@ +namespace Praktika +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + button9 = new Button(); + button6 = new Button(); + button5 = new Button(); + button4 = new Button(); + button3 = new Button(); + button2 = new Button(); + button1 = new Button(); + panel2 = new Panel(); + arrayTextBox = new RichTextBox(); + panel3 = new Panel(); + richTextBox1 = new RichTextBox(); + button10 = new Button(); + label4 = new Label(); + label3 = new Label(); + label2 = new Label(); + textBoxMax = new TextBox(); + textBoxMin = new TextBox(); + label1 = new Label(); + textBoxLen = new TextBox(); + button8 = new Button(); + button7 = new Button(); + panel1.SuspendLayout(); + panel2.SuspendLayout(); + panel3.SuspendLayout(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(button9); + panel1.Controls.Add(button6); + panel1.Controls.Add(button5); + panel1.Controls.Add(button4); + panel1.Controls.Add(button3); + panel1.Controls.Add(button2); + panel1.Controls.Add(button1); + panel1.Dock = DockStyle.Left; + panel1.Location = new Point(0, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(176, 653); + panel1.TabIndex = 0; + // + // button9 + // + button9.BackColor = Color.DarkViolet; + button9.Location = new Point(12, 324); + button9.Name = "button9"; + button9.Size = new Size(147, 41); + button9.TabIndex = 6; + button9.Text = "Вывод задания "; + button9.UseVisualStyleBackColor = false; + button9.Click += Button9_Click; + // + // button6 + // + button6.BackColor = Color.Crimson; + button6.Location = new Point(3, 222); + button6.Name = "button6"; + button6.Size = new Size(165, 36); + button6.TabIndex = 5; + button6.Text = "Задание 6"; + button6.UseVisualStyleBackColor = false; + // + // button5 + // + button5.BackColor = Color.Crimson; + button5.Location = new Point(3, 180); + button5.Name = "button5"; + button5.Size = new Size(165, 36); + button5.TabIndex = 4; + button5.Text = "задание 5"; + button5.UseVisualStyleBackColor = false; + button5.Click += Button5_Click; + // + // button4 + // + button4.BackColor = Color.Crimson; + button4.Location = new Point(3, 138); + button4.Name = "button4"; + button4.Size = new Size(165, 36); + button4.TabIndex = 3; + button4.Text = "Задание 4"; + button4.UseVisualStyleBackColor = false; + button4.Click += Button4_Click; + // + // button3 + // + button3.BackColor = Color.Crimson; + button3.Location = new Point(3, 96); + button3.Name = "button3"; + button3.Size = new Size(165, 36); + button3.TabIndex = 2; + button3.Text = "Задание 3"; + button3.UseVisualStyleBackColor = false; + button3.Click += Button3_Click; + // + // button2 + // + button2.BackColor = Color.Crimson; + button2.Location = new Point(3, 54); + button2.Name = "button2"; + button2.Size = new Size(165, 36); + button2.TabIndex = 1; + button2.Text = "Задание 2"; + button2.UseVisualStyleBackColor = false; + button2.Click += Button2_Click; + // + // button1 + // + button1.BackColor = Color.Crimson; + button1.Location = new Point(3, 12); + button1.Name = "button1"; + button1.Size = new Size(165, 36); + button1.TabIndex = 0; + button1.Text = "Задание 1"; + button1.UseVisualStyleBackColor = false; + button1.Click += Button1_Click; + // + // panel2 + // + panel2.Controls.Add(arrayTextBox); + panel2.Controls.Add(panel3); + panel2.Controls.Add(label4); + panel2.Controls.Add(label3); + panel2.Controls.Add(label2); + panel2.Controls.Add(textBoxMax); + panel2.Controls.Add(textBoxMin); + panel2.Controls.Add(label1); + panel2.Controls.Add(textBoxLen); + panel2.Controls.Add(button8); + panel2.Controls.Add(button7); + panel2.Dock = DockStyle.Right; + panel2.Location = new Point(697, 0); + panel2.Name = "panel2"; + panel2.Size = new Size(238, 653); + panel2.TabIndex = 1; + // + // arrayTextBox + // + arrayTextBox.Location = new Point(26, 12); + arrayTextBox.Name = "arrayTextBox"; + arrayTextBox.Size = new Size(185, 120); + arrayTextBox.TabIndex = 11; + arrayTextBox.Text = ""; + // + // panel3 + // + panel3.Controls.Add(richTextBox1); + panel3.Controls.Add(button10); + panel3.Location = new Point(26, 390); + panel3.Name = "panel3"; + panel3.Size = new Size(200, 251); + panel3.TabIndex = 10; + // + // richTextBox1 + // + richTextBox1.Location = new Point(12, 12); + richTextBox1.Name = "richTextBox1"; + richTextBox1.Size = new Size(173, 173); + richTextBox1.TabIndex = 12; + richTextBox1.Text = ""; + // + // button10 + // + button10.BackColor = Color.Blue; + button10.Location = new Point(36, 200); + button10.Name = "button10"; + button10.Size = new Size(142, 37); + button10.TabIndex = 1; + button10.Text = "Вывод результата"; + button10.UseVisualStyleBackColor = false; + button10.Click += button10_Click; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(26, 201); + label4.Name = "label4"; + label4.Size = new Size(199, 15); + label4.TabIndex = 9; + label4.Text = "Диапазон генерируемых значений"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(174, 243); + label3.Name = "label3"; + label3.Size = new Size(30, 15); + label3.TabIndex = 8; + label3.Text = "Max"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(39, 243); + label2.Name = "label2"; + label2.Size = new Size(28, 15); + label2.TabIndex = 7; + label2.Text = "Min"; + // + // textBoxMax + // + textBoxMax.Location = new Point(141, 273); + textBoxMax.Name = "textBoxMax"; + textBoxMax.Size = new Size(85, 23); + textBoxMax.TabIndex = 6; + // + // textBoxMin + // + textBoxMin.Location = new Point(15, 273); + textBoxMin.Name = "textBoxMin"; + textBoxMin.Size = new Size(81, 23); + textBoxMin.TabIndex = 5; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(26, 159); + label1.Name = "label1"; + label1.Size = new Size(91, 15); + label1.TabIndex = 4; + label1.Text = "Длина массива"; + // + // textBoxLen + // + textBoxLen.Location = new Point(123, 159); + textBoxLen.Name = "textBoxLen"; + textBoxLen.Size = new Size(101, 23); + textBoxLen.TabIndex = 3; + // + // button8 + // + button8.BackColor = Color.Chartreuse; + button8.Location = new Point(15, 341); + button8.Name = "button8"; + button8.Size = new Size(211, 33); + button8.TabIndex = 2; + button8.Text = "Генерация двумерного массива"; + button8.UseVisualStyleBackColor = false; + button8.Click += ButtonTwo_Click; + // + // button7 + // + button7.BackColor = Color.Chartreuse; + button7.Location = new Point(15, 302); + button7.Name = "button7"; + button7.Size = new Size(211, 33); + button7.TabIndex = 1; + button7.Text = "Генерация одномерного массива"; + button7.UseVisualStyleBackColor = false; + button7.Click += ButtonOne_Click; + // + // Form1 + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(935, 653); + Controls.Add(panel2); + Controls.Add(panel1); + Name = "Form1"; + Text = "Form1"; + panel1.ResumeLayout(false); + panel2.ResumeLayout(false); + panel2.PerformLayout(); + panel3.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button button6; + private Button button5; + private Button button4; + private Button button3; + private Button button2; + private Button button1; + private Panel panel2; + private Button button7; + private Label label4; + private Label label3; + private Label label2; + private TextBox textBoxMax; + private TextBox textBoxMin; + private Label label1; + private TextBox textBoxLen; + private Button button8; + private Button button9; + private Panel panel3; + private Button button10; + private RichTextBox arrayTextBox; + private RichTextBox richTextBox1; + } +} \ No newline at end of file diff --git a/Praktika/Form1.cs b/Praktika/Form1.cs new file mode 100644 index 0000000..0643563 --- /dev/null +++ b/Praktika/Form1.cs @@ -0,0 +1,234 @@ +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; + +namespace Praktika +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + + } + int[,] array2D; + public static int flag = 0; + private void ButtonOne_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxLen.Text) || string.IsNullOrEmpty(textBoxMin.Text) || string.IsNullOrEmpty(textBoxMax.Text)) + { + MessageBox.Show(", ."); + return; + } + int[] array = new int[Convert.ToInt32(textBoxLen.Text)]; + Random random = new Random(); + for (int i = 0; i < array.Length; i++) + { + array[i] = random.Next(Convert.ToInt32(textBoxMin.Text), Convert.ToInt32(textBoxMax.Text)); + } + arrayTextBox.Text = string.Join(", ", array); + } + + private void ButtonTwo_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxLen.Text) || string.IsNullOrEmpty(textBoxMin.Text) || string.IsNullOrEmpty(textBoxMax.Text)) + { + MessageBox.Show(", ."); + return; + } + int rows = Convert.ToInt32(textBoxLen.Text); + int columns = Convert.ToInt32(textBoxLen.Text); + array2D = new int[rows, columns]; + Random random = new Random(); + for (int i = 0; i < rows; i++) + { + for (int j = 0; j < columns; j++) + { + array2D[i, j] = random.Next(Convert.ToInt32(textBoxMin.Text), Convert.ToInt32(textBoxMax.Text)); + } + } + // + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < rows; i++) + { + for (int j = 0; j < columns; j++) + { + + sb.Append(array2D[i, j] + " "); + } + sb.AppendLine(); + } + arrayTextBox.Text = sb.ToString(); + } + + private void Button1_Click(object sender, EventArgs e) + { + int[] array = Array.ConvertAll(arrayTextBox.Text.Split(','), int.Parse); + int maxLength = 0; + int seriesStartIndex = 0; + int seriesLength = 0; + + for (int i = 1; i < array.Length; i++) + { + int currentLength = 1; + for (int j = i; j < array.Length - 1; j++) + { + if (array[j] % array[j - 1] == 0) + { + currentLength++; + } + else + { + break; + } + } + + if (currentLength > maxLength && currentLength >= 2) + { + maxLength = currentLength; + seriesStartIndex = i - 1; + seriesLength = currentLength; + } + } + MessageBox.Show($" {seriesStartIndex} {seriesLength}"); + flag = 1; + } + + private void Button9_Click(object sender, EventArgs e) + { + if (flag == 1) + { + richTextBox1.Text = " N." + + " , ." + + " . " + + " 2 . " + + ". . " + + " ."; + } + else if (flag == 2) + { + richTextBox1.Text = ""; + } + else if (flag == 3) + { + richTextBox1.Text = ""; + } + else if (flag == 4) + { + richTextBox1.Text = ""; + } + else if (flag == 5) + { + richTextBox1.Text = ""; + } + else if (flag == 6) + { + richTextBox1.Text = ""; + } + else + { + MessageBox.Show(", "); + } + } + + private void button10_Click(object sender, EventArgs e) + { + if (flag == 1) + { + + } + } + + private void Button2_Click(object sender, EventArgs e) + { + int[] array = Array.ConvertAll(arrayTextBox.Text.Split(','), int.Parse); + int Min = int.MaxValue, minIndex = -1, Max = int.MinValue, maxIndex = -1; + + for (int i = 0; i < array.Length; i++) + { + if (array[i] > Max && array[i] < 0) + { + Max = array[i]; + maxIndex = i; + } + if (array[i] < Min && array[i] > 0) + { + Min = array[i]; + minIndex = i; + } + } + int begin = Math.Min(minIndex, maxIndex) + 1, end = Math.Max(minIndex, maxIndex) - 1; + for (; begin < end; begin++, end--) + { + int tmp = array[begin]; + array[begin] = array[end]; + array[end] = tmp; + } + richTextBox1.Text = string.Join(", ", array); + } + + private void Button3_Click(object sender, EventArgs e) + { + int[] array = Array.ConvertAll(arrayTextBox.Text.Split(','), int.Parse); + + for (int i = 0; i < array.Length; i++) + { + if (array[i] < 0) + { + Array.Resize(ref array, array.Length + 1); // 1 + for (int j = array.Length - 1; j > i + 1; j--) // 1 + { + array[j] = array[j - 1]; + } + array[i + 1] = -1; // 2 + i++; // , 2 + } + + } + richTextBox1.Text = string.Join(", ", array); + } + + private void Button4_Click(object sender, EventArgs e) + { + int[] array = Array.ConvertAll(arrayTextBox.Text.Split(','), int.Parse); + + for (int i = 0; i < array.Length; i++) + { + if (array[i] < 0) + { + // 1 + for (int j = i; j < array.Length - 1; j++) // 1 + { + array[j] = array[j + 1]; + } + + Array.Resize(ref array, array.Length - 1); + i--; + } + + } + richTextBox1.Text = string.Join(", ", array); + } + + private void Button5_Click(object sender, EventArgs e) + { + /* int m = arrayTextBox.Lines.Length-1; + int n = arrayTextBox.Lines[0].Split(' ').Length-1; + int[,] array = new int[m, n]; + for (int i = 0; i < m; i++) + { + string[] s = arrayTextBox.Lines[i].Split(' '); + for (int j = 0; j < n; j++) + { + array[i, j] = Int32.Parse(s[j]); + } + } + richTextBox1.Text = string.Join(", ", array);*/ + + int[,] array2 = array2D; + + } + } +} \ No newline at end of file diff --git a/Praktika/Form1.resx b/Praktika/Form1.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/Praktika/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Praktika/Praktika.csproj b/Praktika/Praktika.csproj new file mode 100644 index 0000000..e1a0735 --- /dev/null +++ b/Praktika/Praktika.csproj @@ -0,0 +1,11 @@ + + + + WinExe + net7.0-windows + enable + true + enable + + + \ No newline at end of file diff --git a/Praktika/Praktika.sln b/Praktika/Praktika.sln new file mode 100644 index 0000000..b401e46 --- /dev/null +++ b/Praktika/Praktika.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34024.191 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Praktika", "Praktika.csproj", "{2C6BDC90-C996-43F3-B279-8B6A900A2FB4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2C6BDC90-C996-43F3-B279-8B6A900A2FB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2C6BDC90-C996-43F3-B279-8B6A900A2FB4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2C6BDC90-C996-43F3-B279-8B6A900A2FB4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2C6BDC90-C996-43F3-B279-8B6A900A2FB4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {773D3F46-22AE-4613-9642-4D42EC797068} + EndGlobalSection +EndGlobal diff --git a/Praktika/Program.cs b/Praktika/Program.cs new file mode 100644 index 0000000..e8136d1 --- /dev/null +++ b/Praktika/Program.cs @@ -0,0 +1,17 @@ +namespace Praktika +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new Form1()); + } + } +} \ No newline at end of file