183 lines
5.3 KiB
C#
183 lines
5.3 KiB
C#
|
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 = "<22><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> N <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|||
|
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("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> !");
|
|||
|
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("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> !");
|
|||
|
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<int, int> c;
|
|||
|
c = new Dictionary<int, int>();
|
|||
|
foreach (int i in array1)
|
|||
|
{
|
|||
|
if (c.ContainsKey(i))
|
|||
|
{
|
|||
|
c[i]++;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
c[i] = 1;
|
|||
|
}
|
|||
|
}
|
|||
|
Maxx = c.Max(x => x.Value);
|
|||
|
textBoxEnd.Text += "M<><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> " + 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)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|