Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Отчёт по массиву.docx
Скачиваний:
0
Добавлен:
30.09.2026
Размер:
1 Мб
Скачать
☆
    1. Текст программы

#include <vector>

#include <iostream>

#include <fstream>

#include <numeric>

#include <algorithm>

#include <iterator>

#include <string>

#include <memory.h>

#include <string.h>

#include <regex>

#pragma once

namespace ProjectRamil {

using namespace System;

using namespace System::Globalization;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

using namespace System::IO;

using namespace System::Text::RegularExpressions;

/// <summary>

/// Сводка для MyForm

/// </summary>

public ref class MyForm : public System::Windows::Forms::Form

{

public:

MyForm(void)

{

InitializeComponent();

//

//TODO: добавьте код конструктора

//

}

protected:

/// <summary>

/// Освободить все используемые ресурсы.

/// </summary>

~MyForm()

{

if (components)

{

delete components;

}

}

private: System::Windows::Forms::Label^ label1;

private: System::Windows::Forms::Label^ label4;

private: System::Windows::Forms::Label^ label5;

private: System::Windows::Forms::Label^ label6;

private: System::Windows::Forms::TextBox^ inputCount;

private: System::Windows::Forms::TextBox^ inputMax;

private: System::Windows::Forms::TextBox^ inputMin;

private: System::Windows::Forms::GroupBox^ groupBox1;

private: System::Windows::Forms::Label^ label2;

private: System::Windows::Forms::TextBox^ inputArray;

private: System::Windows::Forms::Label^ label3;

private: System::Windows::Forms::RadioButton^ rbSum;

private: System::Windows::Forms::RadioButton^ rbMean;

private: System::Windows::Forms::RadioButton^ rbMin;

private: System::Windows::Forms::RadioButton^ rbSortDown;

private: System::Windows::Forms::RadioButton^ rbSortUp;

private: System::Windows::Forms::RadioButton^ rbUneven;

private: System::Windows::Forms::RadioButton^ rbEven;

private: System::Windows::Forms::GroupBox^ groupBox2;

private: System::Windows::Forms::Label^ label7;

private: System::Windows::Forms::TextBox^ inputRes;

private: System::Windows::Forms::Button^ btnGenerate;

private: System::Windows::Forms::Label^ label8;

private: System::Windows::Forms::TextBox^ inputOpenFile;

private: System::Windows::Forms::Button^ inputEnterFile;

private: System::Windows::Forms::Button^ btnCalc;

private: System::Windows::Forms::TextBox^ InputSaveFile;

private: System::Windows::Forms::Label^ label9;

private: System::Windows::Forms::Button^ btnSave;

private: System::Windows::Forms::Button^ btnClose;

protected:

private:

int x1; // Вспомогательная переменная (проверяет наличие минуса в строке)

double x3; // Вводимое действительное число

char ds; // Символ десятичного разделителя

private: System::Windows::Forms::OpenFileDialog^ openFileDialogSave;

private: System::Windows::Forms::OpenFileDialog^ openFileDialogEnter;

private: System::Windows::Forms::RadioButton^ rbMax;

/// <summary>

/// Обязательная переменная конструктора.

/// </summary>

System::ComponentModel::Container^ components;

#pragma region Windows Form Designer generated code

/// <summary>

/// Требуемый метод для поддержки конструктора — не изменяйте

/// содержимое этого метода с помощью редактора кода.

/// </summary>

void InitializeComponent(void)

{

this->label1 = (gcnew System::Windows::Forms::Label());

this->label4 = (gcnew System::Windows::Forms::Label());

this->label5 = (gcnew System::Windows::Forms::Label());

this->label6 = (gcnew System::Windows::Forms::Label());

this->inputCount = (gcnew System::Windows::Forms::TextBox());

this->inputMax = (gcnew System::Windows::Forms::TextBox());

this->inputMin = (gcnew System::Windows::Forms::TextBox());

this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());

this->label2 = (gcnew System::Windows::Forms::Label());

this->inputArray = (gcnew System::Windows::Forms::TextBox());

this->label3 = (gcnew System::Windows::Forms::Label());

this->rbSum = (gcnew System::Windows::Forms::RadioButton());

this->rbMean = (gcnew System::Windows::Forms::RadioButton());

this->rbMax = (gcnew System::Windows::Forms::RadioButton());

this->rbMin = (gcnew System::Windows::Forms::RadioButton());

this->rbSortDown = (gcnew System::Windows::Forms::RadioButton());

this->rbSortUp = (gcnew System::Windows::Forms::RadioButton());

this->rbUneven = (gcnew System::Windows::Forms::RadioButton());

this->rbEven = (gcnew System::Windows::Forms::RadioButton());

this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());

this->label7 = (gcnew System::Windows::Forms::Label());

this->inputRes = (gcnew System::Windows::Forms::TextBox());

this->btnGenerate = (gcnew System::Windows::Forms::Button());

this->label8 = (gcnew System::Windows::Forms::Label());

this->inputOpenFile = (gcnew System::Windows::Forms::TextBox());

this->inputEnterFile = (gcnew System::Windows::Forms::Button());

this->btnCalc = (gcnew System::Windows::Forms::Button());

this->InputSaveFile = (gcnew System::Windows::Forms::TextBox());

this->label9 = (gcnew System::Windows::Forms::Label());

this->btnSave = (gcnew System::Windows::Forms::Button());

this->btnClose = (gcnew System::Windows::Forms::Button());

this->openFileDialogSave = (gcnew System::Windows::Forms::OpenFileDialog());

this->openFileDialogEnter = (gcnew System::Windows::Forms::OpenFileDialog());

this->SuspendLayout();

//

// label1

//

this->label1->AutoSize = true;

this->label1->Font = (gcnew System::Drawing::Font(L"Times New Roman", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->label1->ForeColor = System::Drawing::Color::Blue;

this->label1->Location = System::Drawing::Point(27, 32);

this->label1->Name = L"label1";

this->label1->Size = System::Drawing::Size(136, 19);

this->label1->TabIndex = 0;

this->label1->Text = L"Исходные данные";

//

// label4

//

this->label4->AutoSize = true;

this->label4->Font = (gcnew System::Drawing::Font(L"Times New Roman", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->label4->ForeColor = System::Drawing::SystemColors::ActiveCaptionText;

this->label4->Location = System::Drawing::Point(36, 69);

this->label4->Name = L"label4";

this->label4->Size = System::Drawing::Size(237, 19);

this->label4->TabIndex = 3;

this->label4->Text = L"Количество элементов массива:";

//

// label5

//

this->label5->AutoSize = true;

this->label5->Font = (gcnew System::Drawing::Font(L"Times New Roman", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->label5->ForeColor = System::Drawing::SystemColors::ActiveCaptionText;

this->label5->Location = System::Drawing::Point(36, 126);

this->label5->Name = L"label5";

this->label5->Size = System::Drawing::Size(259, 19);

this->label5->TabIndex = 4;

this->label5->Text = L"Максимальное значение диапазона:";

//

// label6

//

this->label6->AutoSize = true;

this->label6->Font = (gcnew System::Drawing::Font(L"Times New Roman", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->label6->ForeColor = System::Drawing::SystemColors::ActiveCaptionText;

this->label6->Location = System::Drawing::Point(36, 98);

this->label6->Name = L"label6";

this->label6->Size = System::Drawing::Size(252, 19);

this->label6->TabIndex = 5;

this->label6->Text = L"Минимальное значение диапазона:";

//

// inputCount

//

this->inputCount->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;

this->inputCount->ForeColor = System::Drawing::SystemColors::WindowText;

this->inputCount->Location = System::Drawing::Point(357, 67);

this->inputCount->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->inputCount->Name = L"inputCount";

this->inputCount->Size = System::Drawing::Size(146, 22);

this->inputCount->TabIndex = 6;

this->inputCount->TextAlign = System::Windows::Forms::HorizontalAlignment::Right;

this->inputCount->TextChanged += gcnew System::EventHandler(this, &MyForm::inputCount_TextChanged);

this->inputCount->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::inputCount_KeyPress);

//

// inputMax

//

this->inputMax->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;

this->inputMax->Location = System::Drawing::Point(357, 125);

this->inputMax->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->inputMax->Name = L"inputMax";

this->inputMax->Size = System::Drawing::Size(146, 22);

this->inputMax->TabIndex = 7;

this->inputMax->TextAlign = System::Windows::Forms::HorizontalAlignment::Right;

this->inputMax->TextChanged += gcnew System::EventHandler(this, &MyForm::inputMax_TextChanged);

this->inputMax->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::inputMax_KeyPress);

//

// inputMin

//

this->inputMin->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;

this->inputMin->Location = System::Drawing::Point(357, 96);

this->inputMin->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->inputMin->Name = L"inputMin";

this->inputMin->Size = System::Drawing::Size(146, 22);

this->inputMin->TabIndex = 8;

this->inputMin->TextAlign = System::Windows::Forms::HorizontalAlignment::Right;

this->inputMin->TextChanged += gcnew System::EventHandler(this, &MyForm::inputMin_TextChanged);

this->inputMin->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::inputMin_KeyPress);

//

// groupBox1

//

this->groupBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->groupBox1->Location = System::Drawing::Point(20, 32);

this->groupBox1->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->groupBox1->Name = L"groupBox1";

this->groupBox1->Padding = System::Windows::Forms::Padding(3, 2, 3, 2);

this->groupBox1->Size = System::Drawing::Size(544, 145);

this->groupBox1->TabIndex = 9;

this->groupBox1->TabStop = false;

//

// label2

//

this->label2->AutoSize = true;

this->label2->Font = (gcnew System::Drawing::Font(L"Times New Roman", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->label2->ForeColor = System::Drawing::Color::Blue;

this->label2->Location = System::Drawing::Point(21, 191);

this->label2->Name = L"label2";

this->label2->Size = System::Drawing::Size(140, 19);

this->label2->TabIndex = 10;

this->label2->Text = L"Исходный массив:";

//

// inputArray

//

this->inputArray->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;

this->inputArray->Location = System::Drawing::Point(20, 213);

this->inputArray->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->inputArray->Name = L"inputArray";

this->inputArray->Size = System::Drawing::Size(544, 22);

this->inputArray->TabIndex = 11;

this->inputArray->TextChanged += gcnew System::EventHandler(this, &MyForm::inputArray_TextChanged);

this->inputArray->KeyDown += gcnew System::Windows::Forms::KeyEventHandler(this, &MyForm::inputArray_KeyDown);

this->inputArray->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::inputArray_KeyPress);

//

// label3

//

this->label3->AutoSize = true;

this->label3->Font = (gcnew System::Drawing::Font(L"Times New Roman", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->label3->ForeColor = System::Drawing::Color::Blue;

this->label3->Location = System::Drawing::Point(27, 260);

this->label3->Name = L"label3";

this->label3->Size = System::Drawing::Size(162, 19);

this->label3->TabIndex = 12;

this->label3->Text = L"Операции с массивом";

//

// rbSum

//

this->rbSum->AutoSize = true;

this->rbSum->Checked = true;

this->rbSum->Font = (gcnew System::Drawing::Font(L"Times New Roman", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->rbSum->Location = System::Drawing::Point(30, 291);

this->rbSum->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->rbSum->Name = L"rbSum";

this->rbSum->Size = System::Drawing::Size(156, 23);

this->rbSum->TabIndex = 13;

this->rbSum->TabStop = true;

this->rbSum->Text = L"Сумма элементов";

this->rbSum->UseVisualStyleBackColor = true;

this->rbSum->CheckedChanged += gcnew System::EventHandler(this, &MyForm::rbSum_CheckedChanged);

//

// rbMean

//

this->rbMean->AutoSize = true;

this->rbMean->Font = (gcnew System::Drawing::Font(L"Times New Roman", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->rbMean->Location = System::Drawing::Point(30, 317);

this->rbMean->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->rbMean->Name = L"rbMean";

this->rbMean->Size = System::Drawing::Size(156, 23);

this->rbMean->TabIndex = 16;

this->rbMean->Text = L"Среднее значение";

this->rbMean->UseVisualStyleBackColor = true;

this->rbMean->CheckedChanged += gcnew System::EventHandler(this, &MyForm::rbMean_CheckedChanged);

//

// rbMax

//

this->rbMax->AutoSize = true;

this->rbMax->Font = (gcnew System::Drawing::Font(L"Times New Roman", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->rbMax->Location = System::Drawing::Point(30, 366);

this->rbMax->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->rbMax->Name = L"rbMax";

this->rbMax->Size = System::Drawing::Size(198, 23);

this->rbMax->TabIndex = 18;

this->rbMax->Text = L"Максимальный элемент";

this->rbMax->UseVisualStyleBackColor = true;

this->rbMax->CheckedChanged += gcnew System::EventHandler(this, &MyForm::rbMax_CheckedChanged);

//

// rbMin

//

this->rbMin->AutoSize = true;

this->rbMin->Font = (gcnew System::Drawing::Font(L"Times New Roman", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->rbMin->Location = System::Drawing::Point(30, 340);

this->rbMin->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->rbMin->Name = L"rbMin";

this->rbMin->Size = System::Drawing::Size(191, 23);

this->rbMin->TabIndex = 17;

this->rbMin->Text = L"Минимальный элемент";

this->rbMin->UseVisualStyleBackColor = true;

this->rbMin->CheckedChanged += gcnew System::EventHandler(this, &MyForm::rbMin_CheckedChanged);

//

// rbSortDown

//

this->rbSortDown->AutoSize = true;

this->rbSortDown->Font = (gcnew System::Drawing::Font(L"Times New Roman", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->rbSortDown->Location = System::Drawing::Point(286, 366);

this->rbSortDown->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->rbSortDown->Name = L"rbSortDown";

this->rbSortDown->Size = System::Drawing::Size(210, 23);

this->rbSortDown->TabIndex = 22;

this->rbSortDown->Text = L"Сортировка по убыванию";

this->rbSortDown->UseVisualStyleBackColor = true;

this->rbSortDown->CheckedChanged += gcnew System::EventHandler(this, &MyForm::rbSortDown_CheckedChanged);

//

// rbSortUp

//

this->rbSortUp->AutoSize = true;

this->rbSortUp->Font = (gcnew System::Drawing::Font(L"Times New Roman", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->rbSortUp->Location = System::Drawing::Point(286, 340);

this->rbSortUp->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->rbSortUp->Name = L"rbSortUp";

this->rbSortUp->Size = System::Drawing::Size(228, 23);

this->rbSortUp->TabIndex = 21;

this->rbSortUp->Text = L"Сортировка по возрастанию";

this->rbSortUp->UseVisualStyleBackColor = true;

this->rbSortUp->CheckedChanged += gcnew System::EventHandler(this, &MyForm::rbSortUp_CheckedChanged);

//

// rbUneven

//

this->rbUneven->AutoSize = true;

this->rbUneven->Font = (gcnew System::Drawing::Font(L"Times New Roman", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->rbUneven->Location = System::Drawing::Point(286, 317);

this->rbUneven->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->rbUneven->Name = L"rbUneven";

this->rbUneven->Size = System::Drawing::Size(173, 23);

this->rbUneven->TabIndex = 20;

this->rbUneven->Text = L"Нечетные элементы";

this->rbUneven->UseVisualStyleBackColor = true;

this->rbUneven->CheckedChanged += gcnew System::EventHandler(this, &MyForm::rbUneven_CheckedChanged);

//

// rbEven

//

this->rbEven->AutoSize = true;

this->rbEven->Font = (gcnew System::Drawing::Font(L"Times New Roman", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->rbEven->Location = System::Drawing::Point(286, 291);

this->rbEven->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->rbEven->Name = L"rbEven";

this->rbEven->Size = System::Drawing::Size(155, 23);

this->rbEven->TabIndex = 19;

this->rbEven->Text = L"Четные элементы";

this->rbEven->UseVisualStyleBackColor = true;

this->rbEven->CheckedChanged += gcnew System::EventHandler(this, &MyForm::rbEven_CheckedChanged);

//

// groupBox2

//

this->groupBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->groupBox2->Location = System::Drawing::Point(20, 260);

this->groupBox2->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->groupBox2->Name = L"groupBox2";

this->groupBox2->Padding = System::Windows::Forms::Padding(3, 2, 3, 2);

this->groupBox2->Size = System::Drawing::Size(544, 145);

this->groupBox2->TabIndex = 10;

this->groupBox2->TabStop = false;

//

// label7

//

this->label7->AutoSize = true;

this->label7->Font = (gcnew System::Drawing::Font(L"Times New Roman", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->label7->ForeColor = System::Drawing::Color::Blue;

this->label7->Location = System::Drawing::Point(33, 416);

this->label7->Name = L"label7";

this->label7->Size = System::Drawing::Size(150, 19);

this->label7->TabIndex = 23;

this->label7->Text = L"Результат операции:";

//

// inputRes

//

this->inputRes->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;

this->inputRes->Location = System::Drawing::Point(20, 438);

this->inputRes->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->inputRes->Name = L"inputRes";

this->inputRes->ReadOnly = true;

this->inputRes->Size = System::Drawing::Size(544, 22);

this->inputRes->TabIndex = 24;

this->inputRes->TextChanged += gcnew System::EventHandler(this, &MyForm::inputRes_TextChanged);

//

// btnGenerate

//

this->btnGenerate->Location = System::Drawing::Point(616, 46);

this->btnGenerate->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->btnGenerate->Name = L"btnGenerate";

this->btnGenerate->Size = System::Drawing::Size(148, 30);

this->btnGenerate->TabIndex = 25;

this->btnGenerate->Text = L"Генерация массива";

this->btnGenerate->UseVisualStyleBackColor = true;

this->btnGenerate->Click += gcnew System::EventHandler(this, &MyForm::btnGenerate_Click);

//

// label8

//

this->label8->AutoSize = true;

this->label8->Font = (gcnew System::Drawing::Font(L"Times New Roman", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->label8->ForeColor = System::Drawing::SystemColors::ActiveCaptionText;

this->label8->Location = System::Drawing::Point(616, 89);

this->label8->Name = L"label8";

this->label8->Size = System::Drawing::Size(135, 19);

this->label8->TabIndex = 26;

this->label8->Text = L"Имя файла ввода:";

//

// inputOpenFile

//

this->inputOpenFile->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;

this->inputOpenFile->Enabled = false;

this->inputOpenFile->ForeColor = System::Drawing::SystemColors::WindowText;

this->inputOpenFile->Location = System::Drawing::Point(616, 113);

this->inputOpenFile->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->inputOpenFile->Name = L"inputOpenFile";

this->inputOpenFile->Size = System::Drawing::Size(146, 22);

this->inputOpenFile->TabIndex = 27;

//

// inputEnterFile

//

this->inputEnterFile->Location = System::Drawing::Point(616, 150);

this->inputEnterFile->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->inputEnterFile->Name = L"inputEnterFile";

this->inputEnterFile->Size = System::Drawing::Size(148, 30);

this->inputEnterFile->TabIndex = 28;

this->inputEnterFile->Text = L"Ввод из файла";

this->inputEnterFile->UseVisualStyleBackColor = true;

this->inputEnterFile->Click += gcnew System::EventHandler(this, &MyForm::inputEnterFile_Click);

//

// btnCalc

//

this->btnCalc->Location = System::Drawing::Point(616, 259);

this->btnCalc->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->btnCalc->Name = L"btnCalc";

this->btnCalc->Size = System::Drawing::Size(148, 30);

this->btnCalc->TabIndex = 29;

this->btnCalc->Text = L"Выполнить";

this->btnCalc->UseVisualStyleBackColor = true;

this->btnCalc->Click += gcnew System::EventHandler(this, &MyForm::btnCalc_Click);

//

// InputSaveFile

//

this->InputSaveFile->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;

this->InputSaveFile->ForeColor = System::Drawing::SystemColors::WindowText;

this->InputSaveFile->Location = System::Drawing::Point(616, 339);

this->InputSaveFile->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->InputSaveFile->Name = L"InputSaveFile";

this->InputSaveFile->Size = System::Drawing::Size(146, 22);

this->InputSaveFile->TabIndex = 31;

//

// label9

//

this->label9->AutoSize = true;

this->label9->Font = (gcnew System::Drawing::Font(L"Times New Roman", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->label9->ForeColor = System::Drawing::SystemColors::ActiveCaptionText;

this->label9->Location = System::Drawing::Point(614, 315);

this->label9->Name = L"label9";

this->label9->Size = System::Drawing::Size(146, 19);

this->label9->TabIndex = 30;

this->label9->Text = L"Имя файла вывода:";

//

// btnSave

//

this->btnSave->Location = System::Drawing::Point(616, 370);

this->btnSave->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->btnSave->Name = L"btnSave";

this->btnSave->Size = System::Drawing::Size(148, 30);

this->btnSave->TabIndex = 32;

this->btnSave->Text = L"Сохранить в файл";

this->btnSave->UseVisualStyleBackColor = true;

this->btnSave->Click += gcnew System::EventHandler(this, &MyForm::btnSave_Click);

//

// btnClose

//

this->btnClose->Location = System::Drawing::Point(616, 432);

this->btnClose->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->btnClose->Name = L"btnClose";

this->btnClose->Size = System::Drawing::Size(148, 30);

this->btnClose->TabIndex = 33;

this->btnClose->Text = L"Закрыть";

this->btnClose->UseVisualStyleBackColor = true;

this->btnClose->Click += gcnew System::EventHandler(this, &MyForm::btnClose_Click);

//

// openFileDialogSave

//

this->openFileDialogSave->FileName = L"openFileDialog1";

//

// openFileDialogEnter

//

this->openFileDialogEnter->FileName = L"openFileDialog1";

//

// MyForm

//

this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);

this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;

this->AutoSizeMode = System::Windows::Forms::AutoSizeMode::GrowAndShrink;

this->ClientSize = System::Drawing::Size(792, 482);

this->Controls->Add(this->btnClose);

this->Controls->Add(this->btnSave);

this->Controls->Add(this->InputSaveFile);

this->Controls->Add(this->label9);

this->Controls->Add(this->btnCalc);

this->Controls->Add(this->inputEnterFile);

this->Controls->Add(this->inputOpenFile);

this->Controls->Add(this->label8);

this->Controls->Add(this->btnGenerate);

this->Controls->Add(this->inputRes);

this->Controls->Add(this->label7);

this->Controls->Add(this->rbSortDown);

this->Controls->Add(this->rbSortUp);

this->Controls->Add(this->rbUneven);

this->Controls->Add(this->rbEven);

this->Controls->Add(this->rbMax);

this->Controls->Add(this->rbMin);

this->Controls->Add(this->rbMean);

this->Controls->Add(this->rbSum);

this->Controls->Add(this->label3);

this->Controls->Add(this->inputArray);

this->Controls->Add(this->label2);

this->Controls->Add(this->inputMin);

this->Controls->Add(this->inputMax);

this->Controls->Add(this->inputCount);

this->Controls->Add(this->label6);

this->Controls->Add(this->label5);

this->Controls->Add(this->label4);

this->Controls->Add(this->label1);

this->Controls->Add(this->groupBox1);

this->Controls->Add(this->groupBox2);

this->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

this->MaximizeBox = false;

this->Name = L"MyForm";

this->Text = L"Обработка массива";

this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);

this->ResumeLayout(false);

this->PerformLayout();

}

#pragma endregion

bool checkvvod = false;

bool check = false;

private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) {

NumberFormatInfo^ nfi = NumberFormatInfo::CurrentInfo;

ds = (char)nfi->NumberDecimalSeparator[0];

}

private: void validateArray()

{

if (inputArray->Text == "")

{

return;

}

array<String^>^ items = inputArray->Text->Split(' ');

String^ newValue = "";

for (int i = 0; i < items->Length; i++)

{

String^ item = items[i];

String^ newItem = "";

for (int j = 0; j < item->Length; j++)

{

// if (item[j] == ',' && !newItem->Contains(",") && newItem != "")

// {

// newItem += ",";

// }

if (Char::IsDigit(item[j]))

{

newItem += item[j];

}

}

if (newItem != "")

{

if (item[0] == '-')

{

newItem = "-" + newItem;

}

if (newItem->EndsWith(","))

{

newItem = newItem->Remove(newItem->Length - 1, 1);

}

newValue = newValue + " " + newItem;

}

}

if (newValue != "")

{

newValue = newValue->Remove(0, 1);

}

inputArray->Text = newValue;

}

//void diapazon()

// {

// int i = 0;

// int max = 0;

// int min = 0;

// int* mas;

// cli::array<String^>^ sNums = inputArray->Text->Split(' ');

// int c = sNums->Length;

// mas = new int[c];

// for (int i = 1; i < c; i++) {

// mas[i] = Int32::Parse(sNums[i]);

// if (mas[i] > max) {

// max = mas[i];

// inputMax->Text = Convert::ToString(max);

// }

// if (mas[i] < min) {

// min = mas[i];

// inputMin->Text = Convert::ToString(min);

// }

// }

// }

void summa() // Сумма элементов

{

inputRes->Text = "";

int sum = 0;

cli::array<String^>^ sNums = inputArray->Text->Split(' ');

int c = sNums->Length;

//inputCount->Text = Convert::ToString(c); // Вывод суммы элементов массива в текстбокс inputRes

int max = 0;

int* mas;

mas = new int[c];

int i = 0;

if (rbSum->Checked == true) {

for (int i = 0; i < c; i++) {

mas[i] = Double::Parse(sNums[i]);

sum += mas[i]; // Сумма элементов массива

inputRes->Text = "Сумма элементов: " + Convert::ToString(sum);

if (mas[i] > max) {

max = mas[i];

//inputMax->Text = Convert::ToString(max);

}

}

}

}

void aryph() // Среднее значение

{

double sum = 0; double i = 0; double aryph = 0;

cli::array<String^>^ sNums = inputArray->Text->Split(' ');

int c = sNums->Length;

// inputCount->Text = Convert::ToString(c); // Вывод среднего значения элементов массива в текстбокс inputRes

int* mas;

mas = new int[c];

if (rbMean->Checked == true) {

for (int i = 0; i < c; i++) {

mas[i] = Int32::Parse(sNums[i]);

sum += (mas[i]);

aryph = round(sum / c * 100) / 100;

inputRes->Text = "Среднее значение: " + Convert::ToString(aryph);

}

}

}

void min() // Минимальный элемент

{

int k = 0;

int i = 0;

cli::array<String^>^ sNums = inputArray->Text->Split(' ');

int c = sNums->Length;

// inputCount->Text = Convert::ToString(c); // Вывод минимального элемента массива в текстбокс inputRes

int* mas;

mas = new int[c];

mas[i] = Double::Parse(sNums[i]);

int min = mas[0];

if (rbMin->Checked == true) {

for (int i = 1; i < c; i++) {

mas[i] = Int32::Parse(sNums[i]);

if (mas[i] < min) {

min = mas[i];

}

}

for (int i = 1; i < c; i++) {

if (mas[i] < mas[k]) {

k = i;

}

}

k = k + 1;

inputRes->Text = "Минимальное элемент: " + Convert::ToString(min);// +". Порядковый номер: " + Convert::ToString(k);

}

}

void max() // Максимальный элемент

{

int k = 0;

int i = 0;

cli::array<String^>^ sNums = inputArray->Text->Split(' ');

int c = sNums->Length;

// inputCount->Text = Convert::ToString(c); // Вывод максимального элемента массива в текстбокс inputRes

int* mas;

mas = new int[c];

mas[i] = Double::Parse(sNums[i]);

int max = mas[0];

if (rbMax->Checked == true) {

for (int i = 1; i < c; i++) {

mas[i] = Int32::Parse(sNums[i]);

if (mas[i] > max) {

max = mas[i];

}

}

for (int i = 1; i < c; ++i) {

if (mas[i] > mas[k]) {

k = i;

}

}

k = k + 1;

inputRes->Text = "Максимальный элемент: " + Convert::ToString(max);// +". Порядковый номер: " + Convert::ToString(k);

}

}

void chet() // Чётные элементы

{

int i = 0;

cli::array<String^>^ sNums = inputArray->Text->Split(' ');

int c = sNums->Length;

// inputCount->Text = Convert::ToString(c); // Вывод чётных элементов массива в текстбокс inputRes

int* mas;

mas = new int[c];

if (rbEven->Checked == true) {

inputRes->Text = "Чётные элементы:";

for (int i = 0; i < c; i++) {

mas[i] = Int32::Parse(sNums[i]);

if (mas[i] % 2 == 0)

inputRes->AppendText(" " + mas[i]);

}

}

}

void nechet() // Нечётные элементы

{

int i = 0;

cli::array<String^>^ sNums = inputArray->Text->Split(' ');

int c = sNums->Length;

// inputCount->Text = Convert::ToString(c); // Вывод нечётных элементов массива в текстбокс inputRes

int* mas;

mas = new int[c];

if (rbUneven->Checked == true) {

inputRes->Text = "Нечётные элементы:";

for (int i = 0; i < c; i++) {

mas[i] = Int32::Parse(sNums[i]);

if (mas[i] % 2 == 1 || mas[i] % 2 == -1)

inputRes->AppendText(" " + mas[i]);

}

}

}

void vozrast() // Сортировка по возрастанию

{

int k = 0;

int i = 0;

cli::array<String^>^ sNums = inputArray->Text->Split(' ');

int c = sNums->Length;

// inputCount->Text = Convert::ToString(c); // Вывод сортировки по возрастанию элементов массива в текстбокс inputRes

int* mas;

mas = new int[c];

if (rbSortUp->Checked == true) {

inputRes->Text = "Сортировка по возрастанию:";

for (int i = 0; i < c; i++)

mas[i] = Int32::Parse(sNums[i]);

for (int i = 0; i < c - 1; i++)

for (int j = i + 1; j < c; j++)

if (mas[j] < mas[i]) {

int tmp = mas[i];

mas[i] = mas[j];

mas[j] = tmp;

}

for (int i = 0; i < c; i++)

inputRes->AppendText(" " + mas[i]);

}

}

void ubiv() // Сортировка по убыванию

{

int k = 0;

int i = 0;

cli::array<String^>^ sNums = inputArray->Text->Split(' ');

int c = sNums->Length;

// inputCount->Text = Convert::ToString(c); // Вывод сортировки по убыванию элементов массива в текстбокс inputRes

int* mas;

mas = new int[c];

if (rbSortDown->Checked == true) {

inputRes->Text = "Сортировка по убыванию:";

for (int i = 0; i < c; i++)

mas[i] = Int32::Parse(sNums[i]);

for (int i = 0; i < c - 1; i++)

for (int j = i + 1; j < c; j++)

if (mas[j] > mas[i]) {

int tmp = mas[i];

mas[i] = mas[j];

mas[j] = tmp;

}

for (int i = 0; i < c; i++)

inputRes->AppendText(" " + mas[i]);

}

}

private: System::Void btnClose_Click(System::Object^ sender, System::EventArgs^ e) {

this->Close();

}

private: System::Void btnCalc_Click(System::Object^ sender, System::EventArgs^ e) {

check = true;

if (inputArray->Text != "" && inputArray->Text != "-") {

if (inputArray->Text->EndsWith("-")) {

MessageBox::Show("Неверно введен исходный массив!", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Warning);

return;

}

inputRes->Text = "";

inputArray->Text = inputArray->Text->Trim(' '); // Удаление последнего пробела

summa();

aryph();

min();

max();

ubiv();

vozrast();

nechet();

chet();

}

else {

MessageBox::Show("Заполните исходный массив!", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Warning);

}

check = false;

}

private: System::Void btnGenerate_Click(System::Object^ sender, System::EventArgs^ e) {

if (inputCount->Text != "" && inputMax->Text != "" && inputMin->Text != "" && inputMax->Text != "-" && inputMin->Text != "-") {

check = true;

inputArray->Text = "";

inputRes->Text = "";

double sum = 0;

double c = System::Convert::ToDouble(inputCount->Text);

int i = 0;

int* mas;

mas = new int[c];

cli::array<String^>^ sNums = inputArray->Text->Split();

Random^ rnd = gcnew Random();

double a = Convert::ToDouble(inputMin->Text);

double b = Convert::ToDouble(inputMax->Text);

if (a <= b) {

for (int i = 0; i < c; i++) {

mas[i] = rnd->Next(a, b + 1);

inputArray->Text += Convert::ToString(mas[i] + " ");

}

}

if (b < a)

{

inputMin->Text = inputMax->Text;

inputMax->Text = Convert::ToString(a);

a = Convert::ToDouble(inputMin->Text);

b = Convert::ToDouble(inputMax->Text);

for (int i = 0; i < c; i++) {

mas[i] = rnd->Next(a, b + 1);

inputArray->Text += Convert::ToString(mas[i] + " ");

}

}

}

else {

MessageBox::Show("Введите исходные данные для массива!", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Warning);

}

check = false;

}

private: System::Void rbSum_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {

inputRes->Text = "";

}

private: System::Void inputArray_TextChanged(System::Object^ sender, System::EventArgs^ e) {

if (!check) {

inputCount->Text = "";

inputMax->Text = "";

inputMin->Text = "";

}

inputRes->Text = "";

//String^ stroka = inputArray->Text;

//stroka = Regex::Replace(stroka, "\\s+", " ");

//inputArray->Text = stroka;

//if (inputArray->Text->Contains(" ")) {

//inputArray->SelectionStart = inputArray->Text->Length;

int pos = inputArray->SelectionStart;

int length = inputArray->Text->Length;

inputArray->Text = inputArray->Text->Replace("--", "-");

inputArray->Text = inputArray->Text->Replace(" ", " ");

inputArray->Text = inputArray->Text->Replace(" - ", " -");

inputArray->Text = inputArray->Text->Replace("- ", "-");

inputArray->Text = inputArray->Text->Replace("0-", "0");

inputArray->Text = inputArray->Text->Replace("1-", "1");

inputArray->Text = inputArray->Text->Replace("2-", "2");

inputArray->Text = inputArray->Text->Replace("3-", "3");

inputArray->Text = inputArray->Text->Replace("4-", "4");

inputArray->Text = inputArray->Text->Replace("5-", "5");

inputArray->Text = inputArray->Text->Replace("6-", "6");

inputArray->Text = inputArray->Text->Replace("7-", "7");

inputArray->Text = inputArray->Text->Replace("8-", "8");

inputArray->Text = inputArray->Text->Replace("9-", "9");

inputArray->Text = inputArray->Text->Replace(" 00", " 0");

inputArray->Text = inputArray->Text->Replace(",", " ");

if (checkvvod == true) { inputArray->Text = inputArray->Text->Replace("-00", " -0"); } // При вводе массива из файла

if (checkvvod == true) { inputArray->Text = inputArray->Text->Replace("-0 ", " 0 "); }

if (checkvvod == false) { inputArray->Text = inputArray->Text->Replace("-0", " 0"); } // При ручном вводе массива

inputArray->Text = inputArray->Text->Replace(" 01", " 1");

inputArray->Text = inputArray->Text->Replace(" 02", " 2");

inputArray->Text = inputArray->Text->Replace(" 03", " 3");

inputArray->Text = inputArray->Text->Replace(" 04", " 4");

inputArray->Text = inputArray->Text->Replace(" 05", " 5");

inputArray->Text = inputArray->Text->Replace(" 06", " 6");

inputArray->Text = inputArray->Text->Replace(" 07", " 7");

inputArray->Text = inputArray->Text->Replace(" 08", " 8");

inputArray->Text = inputArray->Text->Replace(" 09", " 9");

inputArray->Text = inputArray->Text->Replace(".", " ");

inputArray->Text = inputArray->Text->Replace("-01", " -1");

inputArray->Text = inputArray->Text->Replace("-02", " -2");

inputArray->Text = inputArray->Text->Replace("-03", " -3");

inputArray->Text = inputArray->Text->Replace("-04", " -4");

inputArray->Text = inputArray->Text->Replace("-05", " -5");

inputArray->Text = inputArray->Text->Replace("-06", " -6");

inputArray->Text = inputArray->Text->Replace("-07", " -7");

inputArray->Text = inputArray->Text->Replace("-08", " -8");

inputArray->Text = inputArray->Text->Replace("-09", " -9");

inputArray->Text = inputArray->Text->Replace(" ", " "); //

inputArray->Text = inputArray->Text->Replace("a-", " -");

inputArray->Text = inputArray->Text->Replace("b-", " -");

inputArray->Text = inputArray->Text->Replace("c-", " -");

inputArray->Text = inputArray->Text->Replace("d-", " -");

inputArray->Text = inputArray->Text->Replace("e-", " -");

inputArray->Text = inputArray->Text->Replace("f-", " -");

inputArray->Text = inputArray->Text->Replace("e-", " -");

inputArray->Text = inputArray->Text->Replace("g-", " -");

int diff = length - inputArray->Text->Length;

inputArray->SelectionStart = pos == 0 || diff == 0 ? pos : pos - diff;

}

private: System::Void btnSave_Click(System::Object^ sender, System::EventArgs^ e) {

bool isArrayFound = false;

bool isResFound = false;

if (InputSaveFile->Text == "") {

openFileDialogSave->Filter = "txt files (*.txt)|*.txt";

openFileDialogSave->FileName = "";

if (openFileDialogSave->ShowDialog() == System::Windows::Forms::DialogResult::OK)

{

InputSaveFile->Text = openFileDialogSave->FileName;

}

if (inputArray->Text != "" && inputRes->Text != "")

{

try

{

StreamReader^ reader = File::OpenText(openFileDialogSave->FileName);

while (reader->Peek() != -1)

{

String^ line = reader->ReadLine();

if (line && line->Trim() == (String::Format("Исходный Массив: {0}", inputArray->Text)))

{

isArrayFound = true;

}

if (line && line->Trim() == (String::Format(inputRes->Text)))

{

isResFound = true;

}

if (line && line->Trim() == inputRes->Text)

{

isResFound = true;

}

}

reader->Close();

}

catch (System::Exception^ e)

{

MessageBox::Show(e->Message, "Уведомление", MessageBoxButtons::OK, MessageBoxIcon::Error);

return;

}

StreamWriter^ sw = gcnew StreamWriter(openFileDialogSave->FileName, std::ios::app);

if (!isArrayFound)

{

sw->Write("\n");

sw->WriteLine(String::Format("Исходный Массив: {0}", inputArray->Text));

sw->WriteLine(String::Format(inputRes->Text));

MessageBox::Show("Данные были успешно добавлены в файл.", "Уведомление", MessageBoxButtons::OK, MessageBoxIcon::Information);

}

else if (!isResFound)

{

sw->WriteLine(String::Format(inputRes->Text));

MessageBox::Show("Данные были успешно добавлены в файл.", "Уведомление", MessageBoxButtons::OK, MessageBoxIcon::Information);

}

else if (isResFound && isArrayFound) { MessageBox::Show("Данные уже были добавлены в файл.", "Уведомление", MessageBoxButtons::OK, MessageBoxIcon::Information); } // Если и исходный массив, и результат уже есть в файле, то...

sw->Close();

//if (!isResFound && !isArrayFound) {

//

// sw->Write("\n");

// sw->Write("Исходные данные: " + inputArray->Text);

// sw->Write("\r\n" + inputRes->Text);

// sw->Close();

//}

}

}

else if ((inputArray->Text != "" && inputRes->Text != "")) {

try

{

StreamReader^ reader = File::OpenText(openFileDialogSave->FileName);

while (reader->Peek() != -1)

{

String^ line = reader->ReadLine();

if (line && line->Trim() == (String::Format("Исходный Массив: {0}", inputArray->Text)))

{

isArrayFound = true;

}

if (line && line->Trim() == (String::Format(inputRes->Text)))

{

isResFound = true;

}

if (line && line->Trim() == inputRes->Text)

{

isResFound = true;

}

}

reader->Close();

}

catch (System::Exception^ e)

{

MessageBox::Show(e->Message, "Уведомление", MessageBoxButtons::OK, MessageBoxIcon::Error);

return;

}

StreamWriter^ sw = gcnew StreamWriter(openFileDialogSave->FileName, std::ios::app);

if (!isArrayFound)

{

sw->Write("\n");

sw->WriteLine(String::Format("Исходный Массив: {0}", inputArray->Text));

sw->WriteLine(String::Format(inputRes->Text));

MessageBox::Show("Данные были успешно добавлены в файл.", "Уведомление", MessageBoxButtons::OK, MessageBoxIcon::Information);

}

else if (!isResFound)

{

sw->WriteLine(String::Format(inputRes->Text));

MessageBox::Show("Данные были успешно добавлены в файл.", "Уведомление", MessageBoxButtons::OK, MessageBoxIcon::Information);

}

else if (isResFound && isArrayFound) { MessageBox::Show("Данные уже были добавлены в файл.", "Уведомление", MessageBoxButtons::OK, MessageBoxIcon::Information); } // Если и исходный массив, и результат уже есть в файле, то...

sw->Close();

//if (!isResFound && !isArrayFound) {

//

// sw->Write("\n");

// sw->Write("Исходные данные: " + inputArray->Text);

// sw->Write("\r\n" + inputRes->Text);

// sw->Close();

//}

}

else if (inputArray->Text == "" || inputRes->Text == "") {

MessageBox::Show("Все поля должны быть заполнены!", "Уведомление", MessageBoxButtons::OK, MessageBoxIcon::Information);

}

//if (inputArray->Text == "" && inputRes->Text == "") { MessageBox::Show("Все поля должны быть заполнены!", "Уведомление", MessageBoxButtons::OK, MessageBoxIcon::Information); }

}

private: System::Void inputEnterFile_Click(System::Object^ sender, System::EventArgs^ e) {

checkvvod = true;

if (inputOpenFile->Text == "" || inputOpenFile->Text != "") {

openFileDialogEnter->Filter = "txt files (*.txt)|*.txt";

openFileDialogEnter->FileName = "";

if (openFileDialogEnter->ShowDialog() == System::Windows::Forms::DialogResult::OK)

{

inputOpenFile->Text = openFileDialogEnter->FileName;

}

}

{

inputArray->Text = "";

try

{

StreamReader^ reader = File::OpenText(openFileDialogEnter->FileName);

do

{

inputArray->Text += " " + reader->ReadLine();

} while (reader->Peek() != -1);

reader->Close();

validateArray();

inputCount->Text = "";

inputMax->Text = "";

inputMin->Text = "";

}

catch (System::Exception^ e) {}

}

checkvvod = false;

}

private: System::Void inputArray_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {

// Если нажатая клавиша не цифровая.

if (!Char::IsDigit(e->KeyChar))

// Если нажатая клавиша не является клавишей BackSpace.

if (e->KeyChar != (char)Keys::Back)

e->Handled = true; // Запрет ввода

// Запрет ввода повторных нулей в начале числа.

if (e->KeyChar == (char)Keys::D0 ||

e->KeyChar == (char)Keys::NumPad0) // Если нажата клавиша 0

if (inputArray->Text->Length >= 1) // Если строка не пустая

if (inputArray->Text[0] == '0' && inputArray->SelectionStart < 2)

e->Handled = true; // Запрет ввода

if (e->KeyChar == ',') { e->Handled = true; }

if (e->KeyChar == ' ' || e->KeyChar == '-') { e->Handled = false; }

if (inputArray->Text->Length == 0)

if (e->KeyChar == ' ')

e->Handled = true;

}

private: System::Void rbMean_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {

inputRes->Text = "";

}

private: System::Void rbMin_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {

inputRes->Text = "";

}

private: System::Void rbMax_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {

inputRes->Text = "";

}

private: System::Void rbEven_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {

inputRes->Text = "";

}

private: System::Void rbUneven_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {

inputRes->Text = "";

}

private: System::Void rbSortUp_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {

inputRes->Text = "";

}

private: System::Void rbSortDown_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {

inputRes->Text = "";

}

private: System::Void inputCount_TextChanged(System::Object^ sender, System::EventArgs^ e) {

inputRes->Text = "";

}

private: System::Void inputArray_KeyDown(System::Object^ sender, System::Windows::Forms::KeyEventArgs^ e) {

}

private: System::Void inputCount_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {

// Если нажатая клавиша не цифровая.

if (!Char::IsDigit(e->KeyChar))

// Запрет на ввод более одного знака минуса.

if (e->KeyChar != '-' || inputCount->Text->IndexOf('-') != -1)

// Запрет на ввод более одного десятичного разделителя.

if (e->KeyChar != ds || inputCount->Text->IndexOf(ds) != -1)

// Если нажатая клавиша не является клавишей BackSpace.

if (e->KeyChar != (char)Keys::Back)

e->Handled = true; // Запрет ввода

// Запрет ввода повторных нулей в начале числа.

if (e->KeyChar == (char)Keys::D0 ||

e->KeyChar == (char)Keys::NumPad0) // Если нажата клавиша 0

if (inputCount->Text->Length >= 1) // Если строка не пустая

if (inputCount->Text[0] == '0' && inputCount->SelectionStart < 2)

e->Handled = true; // Запрет ввода

if (e->KeyChar == ',' || e->KeyChar == '-') { e->Handled = true; }

}

private: System::Void inputMin_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {

// Если нажатая клавиша не цифровая.

if (!Char::IsDigit(e->KeyChar))

// Запрет на ввод более одного знака минуса.

if (e->KeyChar != '-' || inputMin->Text->IndexOf('-') != -1)

// Запрет на ввод более одного десятичного разделителя.

if (e->KeyChar != ds || inputMin->Text->IndexOf(ds) != -1)

// Если нажатая клавиша не является клавишей BackSpace.

if (e->KeyChar != (char)Keys::Back)

e->Handled = true; // Запрет ввода

// Запрет ввода повторных нулей в начале числа.

if (e->KeyChar == (char)Keys::D0 ||

e->KeyChar == (char)Keys::NumPad0) // Если нажата клавиша 0

if (inputMin->Text->Length >= 1) // Если строка не пустая

if (inputMin->Text[0] == '0' && inputMin->SelectionStart < 2)

e->Handled = true; // Запрет ввода

if (e->KeyChar == ',') { e->Handled = true; }

if (e->KeyChar == '-')

{

if (inputMin->Text->IndexOf('-') != -1)

{

e->Handled = true;

inputMin->Text = inputMin->Text->Trim('-');

inputMin->SelectionStart = inputMin->Text->Length;

}

else

{

e->Handled = true;

inputMin->Text = inputMin->Text->Insert(0, "-");

inputMin->SelectionStart = inputMin->Text->Length;

}

}

}

private: System::Void inputMax_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {

// Если нажатая клавиша не цифровая.

if (!Char::IsDigit(e->KeyChar))

// Запрет на ввод более одного знака минуса.

if (e->KeyChar != '-' || inputMax->Text->IndexOf('-') != -1)

// Запрет на ввод более одного десятичного разделителя.

if (e->KeyChar != ds || inputMax->Text->IndexOf(ds) != -1)

// Если нажатая клавиша не является клавишей BackSpace.

if (e->KeyChar != (char)Keys::Back)

e->Handled = true; // Запрет ввода

// Запрет ввода повторных нулей в начале числа.

if (e->KeyChar == (char)Keys::D0 ||

e->KeyChar == (char)Keys::NumPad0) // Если нажата клавиша 0

if (inputMax->Text->Length >= 1) // Если строка не пустая

if (inputMax->Text[0] == '0' && inputMax->SelectionStart < 2)

e->Handled = true; // Запрет ввода

if (e->KeyChar == ',') { e->Handled = true; }

if (e->KeyChar == '-')

{

if (inputMax->Text->IndexOf('-') != -1)

{

e->Handled = true;

inputMax->Text = inputMax->Text->Trim('-');

inputMax->SelectionStart = inputMax->Text->Length;

}

else

{

e->Handled = true;

inputMax->Text = inputMax->Text->Insert(0, "-");

inputMax->SelectionStart = inputMax->Text->Length;

}

}

}

private: System::Void inputMin_TextChanged(System::Object^ sender, System::EventArgs^ e) {

int pos = inputMin->SelectionStart;

int length = inputMin->Text->Length;

inputMin->Text = inputMin->Text->Replace("0-", "-");

inputMin->Text = inputMin->Text->Replace("1-", "-");

inputMin->Text = inputMin->Text->Replace("2-", "-");

inputMin->Text = inputMin->Text->Replace("3-", "-");

inputMin->Text = inputMin->Text->Replace("4-", "-");

inputMin->Text = inputMin->Text->Replace("5-", "-");

inputMin->Text = inputMin->Text->Replace("6-", "-");

inputMin->Text = inputMin->Text->Replace("7-", "-");

inputMin->Text = inputMin->Text->Replace("8-", "-");

inputMin->Text = inputMin->Text->Replace("9-", "-");

int diff = length - inputMin->Text->Length;

inputMin->SelectionStart = pos == 0 || diff == 0 ? pos : pos - diff;

}

private: System::Void inputMax_TextChanged(System::Object^ sender, System::EventArgs^ e) {

int pos = inputMax->SelectionStart;

int length = inputMax->Text->Length;

inputMax->Text = inputMax->Text->Replace("0-", "-");

inputMax->Text = inputMax->Text->Replace("1-", "-");

inputMax->Text = inputMax->Text->Replace("2-", "-");

inputMax->Text = inputMax->Text->Replace("3-", "-");

inputMax->Text = inputMax->Text->Replace("4-", "-");

inputMax->Text = inputMax->Text->Replace("5-", "-");

inputMax->Text = inputMax->Text->Replace("6-", "-");

inputMax->Text = inputMax->Text->Replace("7-", "-");

inputMax->Text = inputMax->Text->Replace("8-", "-");

inputMax->Text = inputMax->Text->Replace("9-", "-");

int diff = length - inputMax->Text->Length;

inputMax->SelectionStart = pos == 0 || diff == 0 ? pos : pos - diff;

}

private: System::Void inputRes_TextChanged(System::Object^ sender, System::EventArgs^ e) {

}

private: System::Void InputSaveFile_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {

}

};

}