Compare commits

..

3 Commits

Author SHA1 Message Date
155634f1d8 конец 2024-06-29 17:25:47 +04:00
2f17ff6016 конец 1 практики 2024-06-28 09:22:17 +04:00
f5843777d3 половина 1 практики 2024-06-25 22:22:18 +04:00
6 changed files with 1319 additions and 0 deletions

325
Praktika/Form1.Designer.cs generated Normal file
View File

@ -0,0 +1,325 @@
namespace Praktika
{
partial class Form1
{
/// <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()
{
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;
button6.Click += Button6_Click;
//
// 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;
}
}

821
Praktika/Form1.cs Normal file
View File

@ -0,0 +1,821 @@
using System;
using System.Drawing;
using System.Linq;
using System.Reflection;
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;
int[] array;
public static int flag = 0;
string result;
int len;
private void ButtonOne_Click(object sender, EventArgs e)
{
//ââîä äëÿ ñòðîê
if (arrayTextBox.Text.Length > 0 && textBoxLen.Text.Length >5 )
{
Vvod();
return;
}
if (textBoxLen.Text == null)
{
MessageBox.Show("Íå ââåäåíà äëèíà ìàññèâà");
return;
}
if (string.IsNullOrEmpty(textBoxMin.Text) || string.IsNullOrEmpty(textBoxMax.Text))
{
MessageBox.Show("Ïîæàëóéñòà, ââåäèòå âñå íåîáõîäèìûå äàííûå äëÿ ñîçäàíèÿ ìàññèâà.");
return;
}
//âûâîäèò ìàññèâ ñ áîëüøèì ðàçìåðîì
len = Convert.ToInt32(textBoxLen.Text);
array = new int[len * 2];
Random random = new Random();
for (int i = 0; i < len; i++)
{
array[i] = random.Next(Convert.ToInt32(textBoxMin.Text), Convert.ToInt32(textBoxMax.Text));
}
//âûâîäèò ìàññèâ èçáàâëÿþ îò 0
string str = ""; for (int i = 0; i < len; i++)
{
str += array[i].ToString();
str += " ";
}
arrayTextBox.Text = str;
//âûâîäèò îáû÷íûé ìàññèâ
/*len = Convert.ToInt32(textBoxLen.Text);
array = new int[len ];
Random random = new Random();
for (int i = 0; i < len; i++)
{
array[i] = random.Next(Convert.ToInt32(textBoxMin.Text), Convert.ToInt32(textBoxMax.Text));
}*/
//arrayTextBox.Text = string.Join(", ", array);
}
private void Vvod()
{
string[] mas = arrayTextBox.Text.Split(' ');
len = mas.Length;
array = new int[len * 2];
for (int i = 0; i < len; i++)
{
array[i] = Convert.ToInt32(mas[i]);
}
}
private void ButtonTwo_Click(object sender, EventArgs e)
{
if (arrayTextBox.Text.Length > 0 && textBoxLen.Text.Length > 5)
{
Vvod2();
return;
}
if (textBoxLen.Text == null)
{
MessageBox.Show("Íå ââåäåíà äëèíà ìàññèâà");
return;
}
if (string.IsNullOrEmpty(textBoxMin.Text) || string.IsNullOrEmpty(textBoxMax.Text))
{
MessageBox.Show("Ïîæàëóéñòà, ââåäèòå âñå íåîáõîäèìûå äàííûå äëÿ ñîçäàíèÿ ìàññèâà.");
return;
}
len = Convert.ToInt32(textBoxLen.Text);
array2D = new int[len * 2, len * 2];
Random random = new Random();
for (int i = 0; i < len; i++)
{
for (int j = 0; j < len; j++)
{
array2D[i, j] = random.Next(Convert.ToInt32(textBoxMin.Text), Convert.ToInt32(textBoxMax.Text));
}
}
// Âûâîä äâóìåðíîãî ìàññèâà â òåêñòîâîå ïîëå
string str = "";
for (int i = 0; i < len; i++)
{
for (int j = 0; j < len; j++)
{
str += array2D[i, j].ToString();
str += " ";
}
str += "\n";
}
arrayTextBox.Text = str;
/*StringBuilder sb = new StringBuilder();
for (int i = 0; i < len; i++)
{
for (int j = 0; j < len; j++)
{
sb.Append(array2D[i, j] + " ");
}
sb.AppendLine();
}
arrayTextBox.Text = sb.ToString();*/
}
private void Vvod2()
{
string[] mas = arrayTextBox.Text.Split(' ', '\n');
len = Convert.ToInt32(Math.Sqrt(mas.Length));
array2D = new int[len * 2, len * 2];
int c = 0;
for (int i = 0; i < len; i++)
{
for (int j = 0; j < len; j++)
{
array2D[i, j] = Convert.ToInt32(mas[c++]);
}
}
}
private void Button1_Click(object sender, EventArgs e)
{
//Çíàê çíà÷åíèé âñåõ ýëåìåíòîâ ñåðèè îäèíàêîâû. ìèíèìàëüíàÿ ñåðèÿ
int[] array = Array.ConvertAll(arrayTextBox.Text.Split(','), int.Parse);
int minLength = 999;
int seriesStartIndex = 0;
int seriesLength = 0;
int i = 1;
int currentLength = 1;
for (; i < array.Length; i++)
{
if (array[i] < 0 && array[i - 1] < 0 || array[i] >= 0 && array[i - 1] >= 0)
{
currentLength++;
}
else
{
// Åñëè ñåðèÿ çàêîí÷èëàñü
if (currentLength < minLength && currentLength >= 2)
{
minLength = currentLength;
seriesStartIndex = i - currentLength; // Íà÷èíàþ ñ ïðåäûäóùåãî ýëåìåíòà
seriesLength = currentLength;
}
currentLength = 1;
}
}
//ïîñëåäíÿÿ ñåðèÿ
if (currentLength < minLength && currentLength >= 2)
{
minLength = currentLength;
seriesStartIndex = i - currentLength; // Íà÷èíàþ ñ ïðåäûäóùåãî ýëåìåíòà
seriesLength = currentLength;
}
MessageBox.Show($"Ñåðèÿ ñ ìèíèìàëüíîé äëèíîé íà÷èíàåòñÿ ñ ïîçèöèè {seriesStartIndex} è èìååò äëèíó {seriesLength}");
flag = 1;
result = "Ñåðèÿ ñ ìèíèìàëüíîé äëèíîé íà÷èíàåòñÿ ñ ïîçèöèè " + seriesStartIndex + " è èìååò äëèíó " + seriesLength;
}
private void Button9_Click(object sender, EventArgs e)
{
if (flag == 1)
{
richTextBox1.Text = "Äàí öåëî÷èñëåííûé îäíîìåðíûé ìàññèâ ðàçìåðà N. Ñåðèÿ ýòî" +
"ïîñëåäîâàòåëüíîñòü ýëåìåíòîâ ìàññèâà, èäóùèõ äðóã çà äðóãîì. Çíàêè" +
"çíà÷åíèé âñåõ ýëåìåíòîâ ñåðèè îäèíàêîâû(âñå ïîëîæèòåëüíûå èëè âñå" +
"îòðèöàòåëüíûå). Ñåðèÿ äîëæíà ñîäåðæàòü ìèíèìóì 2 ýëåìåíòà.Äëèíà" +
"ñåðèè êîëè÷åñòâî ýëåìåíòîâ â ñåðèè. Íàéòè ñåðèþ ñ ìèíèìàëüíîé" +
"äëèíîé.Âûâåñòè ñ êàêîé ïîçèöèè íà÷èíàåòñÿ ñåðèÿ è åå äëèíó.";
}
else if (flag == 2)
{
richTextBox1.Text = "7. Äàí öåëî÷èñëåííûé îäíîìåðíûé ìàññèâ ðàçìåðà N. Ïåðåñòàâèòü â\r\nîáðàòíîì ïîðÿäêå ýëåìåíòû ìàññèâà, ðàñïîëîæåííûå ìåæäó\r\níàèáîëüøèì ÷åòíûì è íàèìåíüøèì íå÷åòíûì";
}
else if (flag == 3)
{
richTextBox1.Text = "8. Äàí öåëî÷èñëåííûé îäíîìåðíûé ìàññèâ ðàçìåðà N. Âñòàâèòü 3 ïîñëå\r\nêàæäîãî íå÷åòíîãî ýëåìåíòà ìàññèâà (íå÷åòíûé ïî çíà÷åíèþ, à íå ïî\r\nïîðÿäêîâîìó íîìåðó).\r\n\r\n";
}
else if (flag == 4)
{
richTextBox1.Text = "8. Äàí öåëî÷èñëåííûé îäíîìåðíûé ìàññèâ ðàçìåðà N. Óäàëèòü èç ìàññèâà\r\nâñå íå÷åòíûå ýëåìåíòû (íå÷åòíûé ïî çíà÷åíèþ, à íå ïî ïîðÿäêîâîìó\r\níîìåðó).\r\n";
}
else if (flag == 5)
{
richTextBox1.Text = "8. Äàí öåëî÷èñëåííûé äâóìåðíûé ìàññèâ ðàçìåðà N*N. Äîáàâèòü â ìàññèâ\r\nñòðîêó 0 ïîñëå êàæäîé ñòðîêè, â êîòîðîé åñòü õîòÿ áû îäèí ýëåìåíò,\r\nìåíüøèé ïî ìîäóëþ ñðåäíåãî àðèôìåòè÷åñêîãî ýëåìåíòîâ ìàññèâà.";
}
else if (flag == 6)
{
richTextBox1.Text = "8. Äàí öåëî÷èñëåííûé äâóìåðíûé ìàññèâ ðàçìåðà N*N. Óïîðÿäî÷èòü\r\nýëåìåíòû â ìàòðèöå ïî âîçðàñòàíèþ (ñïðàâà íàëåâî, ñíèçó-ââåðõ)";
}
else
{
MessageBox.Show("Ïîæàëóéñòà, âûáåðèòå çàäàíèå");
}
}
/// <summary>
/// ðåçóëüòàò
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button10_Click(object sender, EventArgs e)
{
richTextBox1.Text = result;
}
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] % 2 == 0)
{
Max = array[i];
maxIndex = i;
}
if (array[i] < Min && array[i] % 2 != 0)
{
Min = array[i];
minIndex = i;
}
}
if (maxIndex != -1 && minIndex != -1)
{
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;
}
}
else
{
MessageBox.Show("Íåò ÷åòíîãî èëè íå÷åòíîãî ýëåìåíòà");
return;
}
/*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;
}*/
result = string.Join(", ", array);
flag = 2;
}
private void Button3_Click(object sender, EventArgs e)
{
// Âñòàâèòü 1 ïîñëå êàæäîãî ïîëîæèòåëüíîãî ýëåìåíòà ìàññèâà.
//int[] array = Array.ConvertAll(arrayTextBox.Text.Split(','), int.Parse); // íå äëÿ ñòðîê
/*for (int i = 0; i < len; i++)
{
if (array[i] >= 0 )
{
//Array.Resize(ref array, array.Length + 1); // Óâåëè÷èâàåì ðàçìåð ìàññèâà íà 1
//len++;
for (int j = len - 1; j > i + 1; j--) // Ñäâèãàåì âñå ýëåìåíòû ïîñëå òåêóùåãî íà 1 ïîçèöèþ âïðàâî
{
array[j] = array[j - 1];
}
array[i + 1] = 1; // Âñòàâëÿåì ÷èñëî 1 ïîñëå òåêóùåãî ýëåìåíòà
i++; // Ïðîïóñêàåì ñëåäóþùóþ èòåðàöèþ öèêëà, ÷òîáû íå îáðàáàòûâàòü âñòàâëåííîå ÷èñëî 2
}
}*/
//int n = array.Length;
int count = len;
int i = 0;
for (; i < count; i++)
{
if (array[i] % 2 != 0)
{
for (int j = count; j > i; j--)
{
array[j] = array[j - 1];
}
array[i + 1] = 3;
count++;
i++;
}
}
string str = ""; for (i = 0; i < count; i++)
{
str += array[i].ToString();
str += " ";
}
result = str;
//result = string.Join(", ", array);
/*for (int i = n - 1; i >= 0; i--)
{
if (array[i] > 0)
{
for (int j = n - 1; j > i + 1; j--)
{
array[j] = array[j - 1];
}
array[i + 1] = 1;
len++;
}
}*/
/*int k = 0;
for(int i = 0; i < array.Length; i++)
{
if (array[i] >= 0)
{
k++;
}
}*/ //ïîñ÷èòàòü ñêîëüêî ðåàëüíûõ ýëåìåíòîâ
// Ñîçäàþ íîâûé ìàññèâ ñ óâåëè÷åííûì ðàçìåðîì
/*int[] newArray = new int[array.Length ];
// Ñ÷åò÷èê äëÿ íîâîãî ìàññèâà
int j = 0;
// Ïðîõîæó ïî èñõîäíîìó ìàññèâó
for (int i = 0; i < array.Length; i++)
{
// Êîïèðóþ ýëåìåíò
newArray[j] = array[i];
j++;
// Åñëè ýëåìåíò íåîòðèöàòåëüíûé, âñòàâëÿþ 1
if (array[i] >= 0)
{
newArray[j] = 1; // Âñòàâëÿþ çíà÷åíèå
j++;
}
}
// Îáíîâëÿþ èñõîäíûé ìàññèâ
array = newArray;*/
//result = string.Join(", ", array);
flag = 3;
}
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--;
}
}
result = string.Join(", ", array);*/
int count = len;
int i = 0;
for (; i < count; i++)
{
if (array[i] % 2 != 0)
{
for (int j = i; j < count ; j++)
{
array[j] = array[j + 1];
}
count--;
i--;
if (count == 0)
{
result = "Íåò ýëåìåíòîâ";
return;
}
}
}
string str = " "; for (i = 0; i < count; i++)
{
str += array[i].ToString();
str += " ";
}
result = str;
flag = 4;
}
private void Button5_Click(object sender, EventArgs e)
{
/*int s = 0;
float ar = 0;
for (int j = 0; j < columns; j++)
{
for (int i = 0; i < rows; i++)
{
if (array2D[i, j] >= 0)
{
s += array2D[i, j];
}
}
}
ar = s / rows;
for (int j = 0; j < columns; j++)
{
for (int i = 0; i < rows; i++)
{
if (array2D[i,j] > ar)
{
for (int k = columns; k > j; k--)
{
for (int p = 0; p < rows; p++)
{
array2D[p, k] = 0;
}
}
columns++;
j++;
break;
}
}
}
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();
}
richTextBox1.Text = sb.ToString();
//richTextBox1.Text = array2D.ToString();
//result = string.Join(" ", array2D);*/
int s = 0;
double ar = 0;
int len2 = len;
for (int j = 0; j < len2; j++)
{
for (int i = 0; i < len; i++)
{
if (array2D[i, j] < 0 )
{
s += array2D[i, j];
}
}
}
ar = (double)s / (len * len2);
//çàäàíèå 5
for (int j = 0; j < len2; j++)
{
for (int i = 0; i < len; i++)
{
if (Math.Abs(array2D[i, j]) > ar && array2D[i,j] != 0)
{
for (int k = len2; k > j; k--)
{
for (int p = 0; p < len; p++)
{
array2D[p, k] = array2D[p, k - 1];
}
}
for (int p = 0; p < len; p++)
{
array2D[p, j + 1] = 0;
}
len2++;
j++;
}
}
}
// Âûâîä ðåçóëüòàòà
string str = "";
for (int i = 0; i < len; i++)
{
for (int j = 0; j < len2; j++)
{
str += array2D[i, j].ToString();
str += " ";
}
str += "\n";
}
result = str;
flag = 5;
//çàäàíèå 6
/*int s =0;
double ar ;
int len2 = len;
for (int j = 0; j < len2; j++)
{
for (int i = 0; i < len; i++)
{
s += array2D[i, j];
}
}
ar = (double)s / (len * len2);
for (int i = 0; i < len; i++)
{
for (int j = 0; j < len2; j++)
{
if (Math.Abs(array2D[i, j]) < ar)
{
for (int k = len; k > i; k--)
{
for (int p = 0; p < len2; p++)
{
array2D[k, p] = array2D[k - 1, p];
}
}
for (int p = 0; p < len2; p++)
{
array2D[i + 1, p] = 0;
}
len++;
i++;
break;
}
}
}
// Âûâîä ðåçóëüòàòà
string str = "";
for (int i = 0; i < len; i++)
{
for (int j = 0; j < len2; j++)
{
str += array2D[i, j].ToString();
str += " ";
}
str += "\n";
}
result = str;
flag = 5;*/
/*StringBuilder sbResult = new StringBuilder();
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < columns; j++)
{
sbResult.Append(array2D[i, j] + " ");
}
sbResult.AppendLine();
}
richTextBox1.Text = sbResult.ToString();*/
// Âñòàâëÿåì ñòîëáöû ñ íóëÿìè
/*int insertCount = 0; // Ñ÷åò÷èê âñòàâëåííûõ ñòîëáöîâ
for (int j = 0; j < len2; j++)
{
for (int i = 0; i < len; i++)
{
if (array2D[i, j] > ar)
{
// Ñäâèãàåì ýëåìåíòû ìàññèâà âïðàâî
for (int k = len2 - 1; k > j + insertCount; k--)
{
for (int p = 0; p < len; p++)
{
array2D[p, k] = array2D[p, k - 1];
}
}
// Âñòàâëÿåì ñòîëáåö ñ íóëÿìè
for (int p = 0; p < len; p++)
{
array2D[p, j + insertCount] = 0;
}
insertCount++; // Óâåëè÷èâàåì ñ÷åò÷èê âñòàâëåííûõ ñòîëáöîâ
break;
}
}
}*/
}
private void Button6_Click(object sender, EventArgs e)
{
/*for (int i = 0; i < len; i++)
{
//ñâåðõó âíèç
//SortLP(array2D, i);
//SortSN(array2D, i);
for (int j = 0; j < len; j++)
{
for (int k = 0; k < len; k++)
{
if (array2D[i, k] < array2D[i, k + 1])
{
int temp = array2D[i, k];
array2D[i, k] = array2D[i, k + 1];
array2D[i, k + 1] = temp;
}
}
for (int k = 0; k < len; k++)
{
if (array2D[k, 0] < array2D[k + 1, r])
{
int temp = array2D[k, r];
array2D[k, r] = array2D[k + 1, r];
array2D[k + 1, r] = temp;
}
}
}
}*/
/*for (int i = 0; i < len*len; i++)
{
// Ñîðòèðîâêà ñòðîêè ñëåâà íàïðàâî
for (int row = 0; row < len; row++)
{
for (int k = 0; k < len - 1; k++)
{
if (array2D[row, k] < array2D[row, k + 1])
{
int temp = array2D[row, k];
array2D[row, k] = array2D[row, k + 1];
array2D[row, k + 1] = temp;
}
}
}
// Ñîðòèðîâêà ñòîëáöà ñâåðõó âíèç
for (int col = 0; col < len ; col++)
{
for (int k = 0; k < len ; k++)
{
if (array2D[k, col] < array2D[k + 1, col])
{
int temp = array2D[k, col];
array2D[k, col] = array2D[k + 1, col];
array2D[k + 1, col] = temp;
}
}
}
}*/
//ðåøåíèå ïðàâèëüíîå
/*for (int i = 0; i < len; i++)
{
for (int j = 0; j < len; j++)
{
for (int x = 0; x < len; x++)
{
for (int y = 0; y < len; y++)
{
if (array2D[i, j] > array2D[x, y])
{
int zam = array2D[i, j];
array2D[i, j] = array2D[x, y];
array2D[x, y] = zam;
}
}
}
}
}*/
//ñïðàâî íàëåâî, ñíèçó - ââåðõ
for (int i = len - 1; i >= 0; i--) // Èä¸ì ñ êîíöà ïî ñòðîêàì
{
for (int j = len - 1; j >= 0; j--) // Èä¸ì ñ êîíöà ïî ñòîëáöàì
{
for (int x = len - 1; x >= 0; x--)
{
for (int y = len - 1; y >= 0; y--)
{
if (array2D[i, j] < array2D[x, y])
{
int zam = array2D[i, j];
array2D[i, j] = array2D[x, y];
array2D[x, y] = zam;
}
}
}
}
}
/*//ñëåâà íà ïðàâî
for (int k = 0; k < len; k++)
{
if (array2D[0, k] < array2D[0, k + 1])
{
int temp = array2D[0, k];
array2D[0, k] = array2D[0, k + 1];
array2D[0, k + 1] = temp;
}
}
//ñâåðõó âíèç
for (int k = 0; k < len; k++)
{
if (array2D[k, 0] < array2D[k + 1, 0])
{
int temp = array2D[k, 0];
array2D[k, 0] = array2D[k + 1, 0];
array2D[k + 1, 0] = temp;
}
}*/
// Âûâîä ðåçóëüòàòà
string str = "";
for (int i = 0; i < len; i++)
{
for (int j = 0; j < len; j++)
{
str += array2D[i, j].ToString();
str += " ";
}
str += "\n";
}
result = str;
flag = 6;
}
public void SortLP(int[,] arr,int r)
{
//ñëåâà íà ïðàâî
for (int i = 0; i < len; i++)
{
for (int k = 0; k < len; k++)
{
if (array2D[r, k] < array2D[r, k + 1])
{
int temp = array2D[r, k];
array2D[r, k] = array2D[r, k + 1];
array2D[r, k + 1] = temp;
}
}
}
}
public void SortSN(int[,] arr, int r)
{
//ñÂÅÐÕÓ ÂÍÈÇ
for (int i = 0; i < len; i++)
{
for (int k = 0; k < len; k++)
{
if (array2D[k, r] < array2D[k + 1, r])
{
int temp = array2D[k, r];
array2D[k, r] = array2D[k + 1, r];
array2D[k + 1, r] = temp;
}
}
}
}
}
}

120
Praktika/Form1.resx Normal file
View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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>

11
Praktika/Praktika.csproj Normal file
View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>

25
Praktika/Praktika.sln Normal file
View File

@ -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

17
Praktika/Program.cs Normal file
View File

@ -0,0 +1,17 @@
namespace Praktika
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[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());
}
}
}