From 9927fa2d86d3c162eb18184fd224bbb5e8287c29 Mon Sep 17 00:00:00 2001 From: Anastasia Yazykova Date: Wed, 26 Jun 2024 19:46:47 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=BE=D1=80=D0=BC=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practika/Practika.sln | 25 ++ Practika/Practika/Form1.Designer.cs | 360 ++++++++++++++++++++++++++++ Practika/Practika/Form1.cs | 182 ++++++++++++++ Practika/Practika/Form1.resx | 120 ++++++++++ Practika/Practika/Practika.csproj | 11 + Practika/Practika/Program.cs | 17 ++ 6 files changed, 715 insertions(+) create mode 100644 Practika/Practika.sln create mode 100644 Practika/Practika/Form1.Designer.cs create mode 100644 Practika/Practika/Form1.cs create mode 100644 Practika/Practika/Form1.resx create mode 100644 Practika/Practika/Practika.csproj create mode 100644 Practika/Practika/Program.cs diff --git a/Practika/Practika.sln b/Practika/Practika.sln new file mode 100644 index 0000000..b4ff333 --- /dev/null +++ b/Practika/Practika.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}") = "Practika", "Practika\Practika.csproj", "{CDE4A9EB-9968-44DD-B9CD-C0F6868F2B75}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CDE4A9EB-9968-44DD-B9CD-C0F6868F2B75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CDE4A9EB-9968-44DD-B9CD-C0F6868F2B75}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CDE4A9EB-9968-44DD-B9CD-C0F6868F2B75}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CDE4A9EB-9968-44DD-B9CD-C0F6868F2B75}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0CE325C9-003F-4835-94ED-74B0C1AE0B5A} + EndGlobalSection +EndGlobal diff --git a/Practika/Practika/Form1.Designer.cs b/Practika/Practika/Form1.Designer.cs new file mode 100644 index 0000000..8a5fb8e --- /dev/null +++ b/Practika/Practika/Form1.Designer.cs @@ -0,0 +1,360 @@ +namespace Practika +{ + 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(); + button6 = new Button(); + button5 = new Button(); + button4 = new Button(); + button3 = new Button(); + button2 = new Button(); + button1 = new Button(); + panel2 = new Panel(); + textBoxMax = new TextBox(); + textBoxMin = new TextBox(); + textBoxNumber = new TextBox(); + textBoxTake = new TextBox(); + textBoxMassive = new TextBox(); + button10 = new Button(); + button9 = new Button(); + button8 = new Button(); + button7 = new Button(); + panel3 = new Panel(); + textBoxTask = new TextBox(); + textBoxEnd = new TextBox(); + button11 = new Button(); + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + label4 = new Label(); + label5 = new Label(); + panel1.SuspendLayout(); + panel2.SuspendLayout(); + panel3.SuspendLayout(); + SuspendLayout(); + // + // panel1 + // + 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.Location = new Point(2, 2); + panel1.Name = "panel1"; + panel1.Size = new Size(319, 661); + panel1.TabIndex = 0; + // + // button6 + // + button6.Location = new Point(21, 365); + button6.Name = "button6"; + button6.Size = new Size(272, 34); + button6.TabIndex = 5; + button6.Text = "button6"; + button6.UseVisualStyleBackColor = true; + // + // button5 + // + button5.Location = new Point(21, 300); + button5.Name = "button5"; + button5.Size = new Size(272, 34); + button5.TabIndex = 4; + button5.Text = "button5"; + button5.UseVisualStyleBackColor = true; + // + // button4 + // + button4.Location = new Point(21, 233); + button4.Name = "button4"; + button4.Size = new Size(272, 34); + button4.TabIndex = 3; + button4.Text = "button4"; + button4.UseVisualStyleBackColor = true; + // + // button3 + // + button3.Location = new Point(21, 164); + button3.Name = "button3"; + button3.Size = new Size(272, 34); + button3.TabIndex = 2; + button3.Text = "button3"; + button3.UseVisualStyleBackColor = true; + // + // button2 + // + button2.Location = new Point(21, 96); + button2.Name = "button2"; + button2.Size = new Size(272, 34); + button2.TabIndex = 1; + button2.Text = "button2"; + button2.UseVisualStyleBackColor = true; + // + // button1 + // + button1.Location = new Point(21, 28); + button1.Name = "button1"; + button1.Size = new Size(272, 34); + button1.TabIndex = 0; + button1.Text = "button1"; + button1.UseVisualStyleBackColor = true; + button1.Click += button1_Click; + // + // panel2 + // + panel2.Controls.Add(label3); + panel2.Controls.Add(label2); + panel2.Controls.Add(label1); + panel2.Controls.Add(textBoxMax); + panel2.Controls.Add(textBoxMin); + panel2.Controls.Add(button11); + panel2.Controls.Add(textBoxNumber); + panel2.Controls.Add(textBoxTake); + panel2.Controls.Add(textBoxMassive); + panel2.Controls.Add(button10); + panel2.Controls.Add(button8); + panel2.Controls.Add(button7); + panel2.Location = new Point(327, 2); + panel2.Name = "panel2"; + panel2.Size = new Size(857, 368); + panel2.TabIndex = 1; + // + // textBoxMax + // + textBoxMax.Location = new Point(461, 125); + textBoxMax.Multiline = true; + textBoxMax.Name = "textBoxMax"; + textBoxMax.Size = new Size(87, 37); + textBoxMax.TabIndex = 9; + // + // textBoxMin + // + textBoxMin.Location = new Point(302, 124); + textBoxMin.Multiline = true; + textBoxMin.Name = "textBoxMin"; + textBoxMin.Size = new Size(82, 38); + textBoxMin.TabIndex = 8; + // + // textBoxNumber + // + textBoxNumber.Location = new Point(318, 63); + textBoxNumber.Multiline = true; + textBoxNumber.Name = "textBoxNumber"; + textBoxNumber.Size = new Size(203, 28); + textBoxNumber.TabIndex = 7; + // + // textBoxTake + // + textBoxTake.Location = new Point(602, 28); + textBoxTake.Multiline = true; + textBoxTake.Name = "textBoxTake"; + textBoxTake.Size = new Size(203, 202); + textBoxTake.TabIndex = 6; + // + // textBoxMassive + // + textBoxMassive.Location = new Point(31, 24); + textBoxMassive.Multiline = true; + textBoxMassive.Name = "textBoxMassive"; + textBoxMassive.Size = new Size(203, 206); + textBoxMassive.TabIndex = 5; + // + // button10 + // + button10.Location = new Point(672, 255); + button10.Name = "button10"; + button10.Size = new Size(133, 103); + button10.TabIndex = 4; + button10.Text = "Одномерный (Авто)"; + button10.UseVisualStyleBackColor = true; + button10.Click += button10_Click_1; + // + // button9 + // + button9.Location = new Point(461, 119); + button9.Name = "button9"; + button9.Size = new Size(123, 42); + button9.TabIndex = 3; + button9.Text = "Создать"; + button9.UseVisualStyleBackColor = true; + button9.Click += button9_Click_1; + // + // button8 + // + button8.Location = new Point(190, 255); + button8.Name = "button8"; + button8.Size = new Size(133, 103); + button8.TabIndex = 2; + button8.Text = "Двумерный"; + button8.UseVisualStyleBackColor = true; + button8.Click += button8_Click_1; + // + // button7 + // + button7.Location = new Point(22, 255); + button7.Name = "button7"; + button7.Size = new Size(133, 103); + button7.TabIndex = 1; + button7.Text = "Одномерный"; + button7.UseVisualStyleBackColor = true; + button7.Click += button7_Click_1; + // + // panel3 + // + panel3.Controls.Add(label5); + panel3.Controls.Add(label4); + panel3.Controls.Add(textBoxTask); + panel3.Controls.Add(textBoxEnd); + panel3.Controls.Add(button9); + panel3.Location = new Point(327, 376); + panel3.Name = "panel3"; + panel3.Size = new Size(854, 287); + panel3.TabIndex = 2; + // + // textBoxTask + // + textBoxTask.Location = new Point(22, 47); + textBoxTask.Multiline = true; + textBoxTask.Name = "textBoxTask"; + textBoxTask.Size = new Size(410, 206); + textBoxTask.TabIndex = 7; + // + // textBoxEnd + // + textBoxEnd.Location = new Point(602, 47); + textBoxEnd.Multiline = true; + textBoxEnd.Name = "textBoxEnd"; + textBoxEnd.Size = new Size(203, 206); + textBoxEnd.TabIndex = 6; + // + // button11 + // + button11.Location = new Point(530, 255); + button11.Name = "button11"; + button11.Size = new Size(119, 103); + button11.TabIndex = 2; + button11.Text = "Двумерный(Авто)"; + button11.UseVisualStyleBackColor = true; + button11.Click += button11_Click_1; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(263, 137); + label1.Name = "label1"; + label1.Size = new Size(33, 25); + label1.TabIndex = 10; + label1.Text = "От"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(420, 137); + label2.Name = "label2"; + label2.Size = new Size(35, 25); + label2.TabIndex = 11; + label2.Text = "До"; + label2.Click += label2_Click; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(383, 24); + label3.Name = "label3"; + label3.Size = new Size(72, 25); + label3.TabIndex = 12; + label3.Text = "Размер"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(22, 19); + label4.Name = "label4"; + label4.Size = new Size(79, 25); + label4.TabIndex = 11; + label4.Text = "Задание"; + // + // label5 + // + label5.AutoSize = true; + label5.Location = new Point(602, 19); + label5.Name = "label5"; + label5.Size = new Size(89, 25); + label5.TabIndex = 12; + label5.Text = "Результат"; + // + // Form1 + // + AutoScaleDimensions = new SizeF(10F, 25F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1207, 666); + Controls.Add(panel3); + Controls.Add(panel2); + Controls.Add(panel1); + Name = "Form1"; + Text = "Form1"; + panel1.ResumeLayout(false); + panel2.ResumeLayout(false); + panel2.PerformLayout(); + panel3.ResumeLayout(false); + panel3.PerformLayout(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Panel panel2; + private Panel panel3; + private Button button1; + private Button button6; + private Button button5; + private Button button4; + private Button button3; + private Button button2; + private Button button8; + private Button button7; + private TextBox textBoxMax; + private TextBox textBoxMin; + private TextBox textBoxNumber; + private TextBox textBoxTake; + private TextBox textBoxMassive; + private Button button10; + private Button button9; + private TextBox textBoxTask; + private TextBox textBoxEnd; + private Button button11; + private Label label2; + private Label label1; + private Label label3; + private Label label5; + private Label label4; + } +} \ No newline at end of file diff --git a/Practika/Practika/Form1.cs b/Practika/Practika/Form1.cs new file mode 100644 index 0000000..a2ecf28 --- /dev/null +++ b/Practika/Practika/Form1.cs @@ -0,0 +1,182 @@ +using System.Text; +using System.Windows.Forms; + +namespace Practika +{ + public partial class Form1 : Form + { + private int[] array1; + private int[,] array2; + private int Task = 0; + private int Count = 1; + private int CountLine = 1; + private int Array1size = 1; + private int Min = 0; + private int Max = 0; + + Random random = new Random(); + + public Form1() + { + InitializeComponent(); + array1 = new int[Array1size]; + array2 = new int[Count, CountLine]; + } + + private void button1_Click(object sender, EventArgs e) + { + textBoxTask.Text = " N "; + Task = 1; + textBoxEnd.Clear(); + } + + + + private void button7_Click_1(object sender, EventArgs e) + { + + textBoxMassive.Clear(); + + string input = textBoxTake.Text; + string[] numbers = input.Split(' '); + Array1size = numbers.Length; + array1 = new int[Array1size]; + for (int i = 0; i < Array1size; i++) + { + if (int.TryParse(numbers[i], out int number)) + { + array1[i] = number; + } + else + { + MessageBox.Show(" !"); + return; + } + } + for (int i = 0; i < Array1size; i++) + { + textBoxMassive.Text += array1[i].ToString() + " "; + } + + + + } + + private void button8_Click_1(object sender, EventArgs e) + { + textBoxMassive.Clear(); + + + string input = textBoxTake.Text; + string[] rows = input.Split(';'); + CountLine = rows.Length; + Count = rows[0].Split(' ').Length; + array2 = new int[CountLine, Count]; + for (int i = 0; i < CountLine; i++) + { + string[] numbers = rows[i].Split(' '); + + for (int j = 0; j < Count; j++) + { + if (int.TryParse(numbers[j], out int number)) + { + array2[i, j] = number; + } + else + { + MessageBox.Show(" !"); + return; + } + } + } + for (int i = 0; i < CountLine; i++) + { + for (int j = 0; j < Count; j++) + { + textBoxMassive.Text += array2[i, j].ToString() + " "; + } + textBoxMassive.Text += Environment.NewLine; + } + + } + + private void button9_Click_1(object sender, EventArgs e) + { + + textBoxEnd.Clear(); + switch (Task) + { + case 1: + + int Maxx = 0; + Dictionary c; + c = new Dictionary(); + foreach (int i in array1) + { + if (c.ContainsKey(i)) + { + c[i]++; + } + else + { + c[i] = 1; + } + } + Maxx = c.Max(x => x.Value); + textBoxEnd.Text += "M " + Maxx.ToString(); + break; + } + } + + private void button10_Click_1(object sender, EventArgs e) + { + textBoxMassive.Clear(); + Array1size = Int32.Parse(textBoxNumber.Text); + array1 = new int[Array1size]; + Min = Int32.Parse(textBoxMin.Text); + Max = Int32.Parse(textBoxMax.Text); + for (int i = 0; i < Array1size; i++) + { + array1[i] = random.Next(Min, Max); + } + textBoxMassive.Text = string.Join(", ", array1); + } + + private void button11_Click_1(object sender, EventArgs e) + { + textBoxMassive.Clear(); + CountLine = Int32.Parse(textBoxNumber.Text); + Count = Int32.Parse(textBoxNumber.Text); + Min = Int32.Parse(textBoxMin.Text); + Max = Int32.Parse(textBoxMax.Text); + array2 = new int[CountLine * 2, Count]; + for (int i = 0; i < CountLine; i++) + for (int j = 0; j < Count; j++) + array2[i, j] = random.Next(Min, Max); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < CountLine; i++) + { + for (int j = 0; j < Count; j++) + { + sb.Append(array2[i, j].ToString() + ", "); + } + sb.AppendLine(); + } + for (int i = 0; i < CountLine; i++) + { + for (int j = 0; j < Count; j++) + { + textBoxMassive.Text += array2[i, j].ToString() + " "; + } + textBoxMassive.Text += Environment.NewLine; + } + } + + private void label2_Click(object sender, EventArgs e) + { + + } + } + +} + diff --git a/Practika/Practika/Form1.resx b/Practika/Practika/Form1.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/Practika/Practika/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/Practika/Practika/Practika.csproj b/Practika/Practika/Practika.csproj new file mode 100644 index 0000000..e1a0735 --- /dev/null +++ b/Practika/Practika/Practika.csproj @@ -0,0 +1,11 @@ + + + + WinExe + net7.0-windows + enable + true + enable + + + \ No newline at end of file diff --git a/Practika/Practika/Program.cs b/Practika/Practika/Program.cs new file mode 100644 index 0000000..fe1d8e6 --- /dev/null +++ b/Practika/Practika/Program.cs @@ -0,0 +1,17 @@ +namespace Practika +{ + 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