Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <string>
- #include <vector>
- #include <msclr\marshal_cppstd.h>
- #include <algorithm>
- #include <windows.h>
- namespace lab3OOP {
- using namespace System;
- using namespace System::ComponentModel;
- using namespace System::Collections;
- using namespace System::Windows::Forms;
- using namespace System::Data;
- using namespace System::Drawing;
- std::vector<int> vec;
- bool reversed_sort;
- /// <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::Button^ push_back_button;
- protected:
- protected:
- private: System::Windows::Forms::ListBox^ listBox1;
- private: System::Windows::Forms::ListBox^ listBox2;
- private: System::Windows::Forms::Button^ genr;
- private: System::Windows::Forms::Button^ button2;
- private: System::Windows::Forms::Button^ button1;
- private: System::Windows::Forms::Button^ button3;
- private: System::Windows::Forms::NumericUpDown^ numericUpDown1;
- private: System::Windows::Forms::Button^ button4;
- private: System::Windows::Forms::NumericUpDown^ numericUpDown2;
- private: System::Windows::Forms::Button^ button5;
- private: System::Windows::Forms::NumericUpDown^ numericUpDown3;
- private: System::Windows::Forms::Button^ button6;
- private: System::Windows::Forms::NumericUpDown^ numericUpDown4;
- private: System::Windows::Forms::NumericUpDown^ numericUpDown5;
- private: System::Windows::Forms::Button^ button7;
- private: System::Windows::Forms::NumericUpDown^ numericUpDown6;
- private: System::Windows::Forms::Button^ button8;
- private: System::Windows::Forms::NumericUpDown^ numericUpDown7;
- private: System::Windows::Forms::Button^ button9;
- private: System::Windows::Forms::Button^ button10;
- private: System::Windows::Forms::NumericUpDown^ numericUpDown8;
- private: System::Windows::Forms::Button^ button11;
- private: System::Windows::Forms::NumericUpDown^ numericUpDown9;
- private: System::Windows::Forms::PictureBox^ pictureBox1;
- private: System::Windows::Forms::Button^ button12;
- private: System::Windows::Forms::Button^ button13;
- private: System::Windows::Forms::Button^ button14;
- private:
- /// <summary>
- /// Обязательная переменная конструктора.
- /// </summary>
- System::ComponentModel::Container^ components;
- #pragma region Windows Form Designer generated code
- /// <summary>
- /// Требуемый метод для поддержки конструктора — не изменяйте
- /// содержимое этого метода с помощью редактора кода.
- /// </summary>
- void InitializeComponent(void)
- {
- System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(MyForm::typeid));
- this->push_back_button = (gcnew System::Windows::Forms::Button());
- this->listBox1 = (gcnew System::Windows::Forms::ListBox());
- this->listBox2 = (gcnew System::Windows::Forms::ListBox());
- this->genr = (gcnew System::Windows::Forms::Button());
- this->button2 = (gcnew System::Windows::Forms::Button());
- this->button1 = (gcnew System::Windows::Forms::Button());
- this->button3 = (gcnew System::Windows::Forms::Button());
- this->numericUpDown1 = (gcnew System::Windows::Forms::NumericUpDown());
- this->button4 = (gcnew System::Windows::Forms::Button());
- this->numericUpDown2 = (gcnew System::Windows::Forms::NumericUpDown());
- this->button5 = (gcnew System::Windows::Forms::Button());
- this->numericUpDown3 = (gcnew System::Windows::Forms::NumericUpDown());
- this->button6 = (gcnew System::Windows::Forms::Button());
- this->numericUpDown4 = (gcnew System::Windows::Forms::NumericUpDown());
- this->numericUpDown5 = (gcnew System::Windows::Forms::NumericUpDown());
- this->button7 = (gcnew System::Windows::Forms::Button());
- this->numericUpDown6 = (gcnew System::Windows::Forms::NumericUpDown());
- this->button8 = (gcnew System::Windows::Forms::Button());
- this->numericUpDown7 = (gcnew System::Windows::Forms::NumericUpDown());
- this->button9 = (gcnew System::Windows::Forms::Button());
- this->button10 = (gcnew System::Windows::Forms::Button());
- this->numericUpDown8 = (gcnew System::Windows::Forms::NumericUpDown());
- this->button11 = (gcnew System::Windows::Forms::Button());
- this->numericUpDown9 = (gcnew System::Windows::Forms::NumericUpDown());
- this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
- this->button12 = (gcnew System::Windows::Forms::Button());
- this->button13 = (gcnew System::Windows::Forms::Button());
- this->button14 = (gcnew System::Windows::Forms::Button());
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown1))->BeginInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown2))->BeginInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown3))->BeginInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown4))->BeginInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown5))->BeginInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown6))->BeginInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown7))->BeginInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown8))->BeginInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown9))->BeginInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->BeginInit();
- this->SuspendLayout();
- //
- // push_back_button
- //
- this->push_back_button->Cursor = System::Windows::Forms::Cursors::Hand;
- this->push_back_button->Location = System::Drawing::Point(6, 6);
- this->push_back_button->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->push_back_button->Name = L"push_back_button";
- this->push_back_button->Size = System::Drawing::Size(173, 33);
- this->push_back_button->TabIndex = 0;
- this->push_back_button->Text = L"push_back random";
- this->push_back_button->UseVisualStyleBackColor = true;
- this->push_back_button->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
- //
- // listBox1
- //
- this->listBox1->FormattingEnabled = true;
- this->listBox1->ItemHeight = 19;
- this->listBox1->Location = System::Drawing::Point(353, 48);
- this->listBox1->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->listBox1->Name = L"listBox1";
- this->listBox1->Size = System::Drawing::Size(178, 460);
- this->listBox1->TabIndex = 1;
- //
- // listBox2
- //
- this->listBox2->FormattingEnabled = true;
- this->listBox2->ItemHeight = 19;
- this->listBox2->Location = System::Drawing::Point(6, 48);
- this->listBox2->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->listBox2->Name = L"listBox2";
- this->listBox2->Size = System::Drawing::Size(173, 460);
- this->listBox2->TabIndex = 2;
- //
- // genr
- //
- this->genr->Cursor = System::Windows::Forms::Cursors::Hand;
- this->genr->Location = System::Drawing::Point(186, 48);
- this->genr->Margin = System::Windows::Forms::Padding(1);
- this->genr->Name = L"genr";
- this->genr->Size = System::Drawing::Size(162, 33);
- this->genr->TabIndex = 4;
- this->genr->Text = L"size";
- this->genr->UseVisualStyleBackColor = true;
- this->genr->Click += gcnew System::EventHandler(this, &MyForm::genr_Click);
- //
- // button2
- //
- this->button2->Cursor = System::Windows::Forms::Cursors::Hand;
- this->button2->Location = System::Drawing::Point(186, 85);
- this->button2->Name = L"button2";
- this->button2->Size = System::Drawing::Size(117, 33);
- this->button2->TabIndex = 5;
- this->button2->Text = L"sort";
- this->button2->UseVisualStyleBackColor = true;
- this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
- //
- // button1
- //
- this->button1->Cursor = System::Windows::Forms::Cursors::Hand;
- this->button1->Location = System::Drawing::Point(186, 124);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(162, 33);
- this->button1->TabIndex = 6;
- this->button1->Text = L"reverse";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click_1);
- //
- // button3
- //
- this->button3->Cursor = System::Windows::Forms::Cursors::Hand;
- this->button3->Location = System::Drawing::Point(186, 163);
- this->button3->Name = L"button3";
- this->button3->Size = System::Drawing::Size(117, 33);
- this->button3->TabIndex = 7;
- this->button3->Text = L"count";
- this->button3->UseVisualStyleBackColor = true;
- this->button3->Click += gcnew System::EventHandler(this, &MyForm::button3_Click);
- //
- // numericUpDown1
- //
- this->numericUpDown1->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
- this->numericUpDown1->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 13.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(204)));
- this->numericUpDown1->Location = System::Drawing::Point(309, 163);
- this->numericUpDown1->Name = L"numericUpDown1";
- this->numericUpDown1->Size = System::Drawing::Size(38, 31);
- this->numericUpDown1->TabIndex = 8;
- //
- // button4
- //
- this->button4->Cursor = System::Windows::Forms::Cursors::Hand;
- this->button4->Location = System::Drawing::Point(186, 202);
- this->button4->Name = L"button4";
- this->button4->Size = System::Drawing::Size(117, 33);
- this->button4->TabIndex = 10;
- this->button4->Text = L"fill";
- this->button4->UseVisualStyleBackColor = true;
- this->button4->Click += gcnew System::EventHandler(this, &MyForm::button4_Click);
- //
- // numericUpDown2
- //
- this->numericUpDown2->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
- this->numericUpDown2->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 13.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(204)));
- this->numericUpDown2->Location = System::Drawing::Point(310, 202);
- this->numericUpDown2->Name = L"numericUpDown2";
- this->numericUpDown2->Size = System::Drawing::Size(38, 31);
- this->numericUpDown2->TabIndex = 11;
- //
- // button5
- //
- this->button5->Cursor = System::Windows::Forms::Cursors::Hand;
- this->button5->Location = System::Drawing::Point(186, 241);
- this->button5->Name = L"button5";
- this->button5->Size = System::Drawing::Size(162, 33);
- this->button5->TabIndex = 12;
- this->button5->Text = L"unique";
- this->button5->UseVisualStyleBackColor = true;
- this->button5->Click += gcnew System::EventHandler(this, &MyForm::button5_Click);
- //
- // numericUpDown3
- //
- this->numericUpDown3->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 13.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(204)));
- this->numericUpDown3->Location = System::Drawing::Point(186, 280);
- this->numericUpDown3->Name = L"numericUpDown3";
- this->numericUpDown3->Size = System::Drawing::Size(39, 31);
- this->numericUpDown3->TabIndex = 13;
- //
- // button6
- //
- this->button6->Cursor = System::Windows::Forms::Cursors::Hand;
- this->button6->Location = System::Drawing::Point(231, 280);
- this->button6->Name = L"button6";
- this->button6->Size = System::Drawing::Size(72, 33);
- this->button6->TabIndex = 14;
- this->button6->Text = L"swap";
- this->button6->UseVisualStyleBackColor = true;
- this->button6->Click += gcnew System::EventHandler(this, &MyForm::button6_Click);
- //
- // numericUpDown4
- //
- this->numericUpDown4->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
- this->numericUpDown4->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 13.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(204)));
- this->numericUpDown4->Location = System::Drawing::Point(310, 280);
- this->numericUpDown4->Name = L"numericUpDown4";
- this->numericUpDown4->Size = System::Drawing::Size(38, 31);
- this->numericUpDown4->TabIndex = 15;
- //
- // numericUpDown5
- //
- this->numericUpDown5->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
- this->numericUpDown5->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 13.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(204)));
- this->numericUpDown5->Location = System::Drawing::Point(310, 317);
- this->numericUpDown5->Name = L"numericUpDown5";
- this->numericUpDown5->Size = System::Drawing::Size(38, 31);
- this->numericUpDown5->TabIndex = 16;
- //
- // button7
- //
- this->button7->Cursor = System::Windows::Forms::Cursors::Hand;
- this->button7->Location = System::Drawing::Point(186, 317);
- this->button7->Name = L"button7";
- this->button7->Size = System::Drawing::Size(118, 33);
- this->button7->TabIndex = 17;
- this->button7->Text = L"remove";
- this->button7->UseVisualStyleBackColor = true;
- this->button7->Click += gcnew System::EventHandler(this, &MyForm::button7_Click_1);
- //
- // numericUpDown6
- //
- this->numericUpDown6->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
- this->numericUpDown6->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 13.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(204)));
- this->numericUpDown6->Location = System::Drawing::Point(310, 354);
- this->numericUpDown6->Name = L"numericUpDown6";
- this->numericUpDown6->Size = System::Drawing::Size(38, 31);
- this->numericUpDown6->TabIndex = 20;
- //
- // button8
- //
- this->button8->Cursor = System::Windows::Forms::Cursors::Hand;
- this->button8->Location = System::Drawing::Point(232, 356);
- this->button8->Name = L"button8";
- this->button8->Size = System::Drawing::Size(72, 33);
- this->button8->TabIndex = 19;
- this->button8->Text = L"replace";
- this->button8->UseVisualStyleBackColor = true;
- this->button8->Click += gcnew System::EventHandler(this, &MyForm::button8_Click);
- //
- // numericUpDown7
- //
- this->numericUpDown7->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 13.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(204)));
- this->numericUpDown7->Location = System::Drawing::Point(186, 356);
- this->numericUpDown7->Name = L"numericUpDown7";
- this->numericUpDown7->Size = System::Drawing::Size(38, 31);
- this->numericUpDown7->TabIndex = 18;
- //
- // button9
- //
- this->button9->Cursor = System::Windows::Forms::Cursors::Hand;
- this->button9->Location = System::Drawing::Point(187, 469);
- this->button9->Name = L"button9";
- this->button9->Size = System::Drawing::Size(162, 39);
- this->button9->TabIndex = 21;
- this->button9->Text = L"woof";
- this->button9->UseVisualStyleBackColor = true;
- this->button9->Click += gcnew System::EventHandler(this, &MyForm::button9_Click);
- //
- // button10
- //
- this->button10->Cursor = System::Windows::Forms::Cursors::Hand;
- this->button10->Location = System::Drawing::Point(186, 393);
- this->button10->Name = L"button10";
- this->button10->Size = System::Drawing::Size(118, 33);
- this->button10->TabIndex = 22;
- this->button10->Text = L"rotate";
- this->button10->UseVisualStyleBackColor = true;
- this->button10->Click += gcnew System::EventHandler(this, &MyForm::button10_Click);
- //
- // numericUpDown8
- //
- this->numericUpDown8->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
- this->numericUpDown8->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 13.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(204)));
- this->numericUpDown8->Location = System::Drawing::Point(310, 395);
- this->numericUpDown8->Name = L"numericUpDown8";
- this->numericUpDown8->Size = System::Drawing::Size(38, 31);
- this->numericUpDown8->TabIndex = 23;
- //
- // button11
- //
- this->button11->Cursor = System::Windows::Forms::Cursors::Hand;
- this->button11->Location = System::Drawing::Point(187, 432);
- this->button11->Name = L"button11";
- this->button11->Size = System::Drawing::Size(117, 33);
- this->button11->TabIndex = 24;
- this->button11->Text = L"find";
- this->button11->UseVisualStyleBackColor = true;
- this->button11->Click += gcnew System::EventHandler(this, &MyForm::button11_Click);
- //
- // numericUpDown9
- //
- this->numericUpDown9->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
- this->numericUpDown9->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 13.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(204)));
- this->numericUpDown9->Location = System::Drawing::Point(310, 432);
- this->numericUpDown9->Name = L"numericUpDown9";
- this->numericUpDown9->Size = System::Drawing::Size(38, 31);
- this->numericUpDown9->TabIndex = 25;
- //
- // pictureBox1
- //
- this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox1.Image")));
- this->pictureBox1->Location = System::Drawing::Point(418, 1750);
- this->pictureBox1->Name = L"pictureBox1";
- this->pictureBox1->Size = System::Drawing::Size(480, 273);
- this->pictureBox1->SizeMode = System::Windows::Forms::PictureBoxSizeMode::StretchImage;
- this->pictureBox1->TabIndex = 26;
- this->pictureBox1->TabStop = false;
- this->pictureBox1->Visible = false;
- //
- // button12
- //
- this->button12->Cursor = System::Windows::Forms::Cursors::Hand;
- this->button12->Location = System::Drawing::Point(309, 85);
- this->button12->Name = L"button12";
- this->button12->Size = System::Drawing::Size(39, 33);
- this->button12->TabIndex = 27;
- this->button12->Text = L"R";
- this->button12->UseVisualStyleBackColor = true;
- this->button12->Click += gcnew System::EventHandler(this, &MyForm::button12_Click);
- //
- // button13
- //
- this->button13->Cursor = System::Windows::Forms::Cursors::Hand;
- this->button13->Location = System::Drawing::Point(186, 6);
- this->button13->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->button13->Name = L"button13";
- this->button13->Size = System::Drawing::Size(63, 33);
- this->button13->TabIndex = 28;
- this->button13->Text = L"сlear";
- this->button13->UseVisualStyleBackColor = true;
- this->button13->Click += gcnew System::EventHandler(this, &MyForm::button13_Click);
- //
- // button14
- //
- this->button14->Cursor = System::Windows::Forms::Cursors::Hand;
- this->button14->Location = System::Drawing::Point(353, 6);
- this->button14->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->button14->Name = L"button14";
- this->button14->Size = System::Drawing::Size(178, 33);
- this->button14->TabIndex = 29;
- this->button14->Text = L"clear debug values";
- this->button14->UseVisualStyleBackColor = true;
- this->button14->Click += gcnew System::EventHandler(this, &MyForm::button14_Click);
- //
- // MyForm
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(7, 19);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(537, 514);
- this->Controls->Add(this->button14);
- this->Controls->Add(this->button13);
- this->Controls->Add(this->pictureBox1);
- this->Controls->Add(this->button12);
- this->Controls->Add(this->numericUpDown9);
- this->Controls->Add(this->button11);
- this->Controls->Add(this->numericUpDown8);
- this->Controls->Add(this->button10);
- this->Controls->Add(this->button9);
- this->Controls->Add(this->numericUpDown6);
- this->Controls->Add(this->button8);
- this->Controls->Add(this->numericUpDown7);
- this->Controls->Add(this->button7);
- this->Controls->Add(this->numericUpDown5);
- this->Controls->Add(this->numericUpDown4);
- this->Controls->Add(this->button6);
- this->Controls->Add(this->numericUpDown3);
- this->Controls->Add(this->button5);
- this->Controls->Add(this->numericUpDown2);
- this->Controls->Add(this->button4);
- this->Controls->Add(this->numericUpDown1);
- this->Controls->Add(this->button3);
- this->Controls->Add(this->button1);
- this->Controls->Add(this->button2);
- this->Controls->Add(this->genr);
- this->Controls->Add(this->listBox2);
- this->Controls->Add(this->listBox1);
- this->Controls->Add(this->push_back_button);
- this->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(204)));
- this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle;
- this->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->MaximizeBox = false;
- this->Name = L"MyForm";
- this->Text = L"MyForm";
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown1))->EndInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown2))->EndInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown3))->EndInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown4))->EndInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown5))->EndInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown6))->EndInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown7))->EndInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown8))->EndInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown9))->EndInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->EndInit();
- this->ResumeLayout(false);
- }
- #pragma endregion
- int Random(const int& min, const int& max) {
- return min + std::rand() % (max - min + 1);
- }
- void DebugHandler(std::string message) {
- listBox1->Items->Insert(listBox1->Items->Count, cs(message));
- }void DebugHandler(String^ message) {
- listBox1->Items->Insert(listBox1->Items->Count, message);
- }
- template<typename T>
- void DebugVector(std::vector<T> vec, std::string message) {
- listBox1->Items->Insert(listBox1->Items->Count, cs(message + " ["));
- for (size_t i = 0; i < vec.size(); i++) listBox1->Items->Insert(listBox1->Items->Count, cs(" " + s(vec.at(i))));
- listBox1->Items->Insert(listBox1->Items->Count, cs("]"));
- }
- // converts System::String to std::string
- std::string s(String^ str) {
- return msclr::interop::marshal_as<std::string>(str);
- }std::string s(System::Decimal dec) {
- return std::to_string(decToInt(dec));
- }template<typename T>
- std::string s(const T& value) { // converts ints, floats and anything it can to std::string
- return std::to_string(value);
- }
- // converts std::string to System::String^
- System::String^ cs(std::string str) {
- return gcnew String(str.c_str());
- }
- // the main update function to refresh the vector in listbox
- void update() {
- listBox2->Items->Clear();
- for (size_t i = 0; i < vec.size(); i++)
- listBox2->Items->Insert(listBox2->Items->Count, cs(s(vec.at(i))));
- } // WORKS 1
- // adds random number to the vector
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- vec.push_back(Random(0, 10));
- update();
- }
- // generate(), -> replace with something working in CLR
- private: System::Void genr_Click(System::Object^ sender, System::EventArgs^ e) {
- DebugHandler("size() returns " + s(size(vec)));
- } // NEEDS REPLACE
- // basicly sort, -> added the reverse sort checkbox
- private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
- (button2->Text=="reversed sort") ? std::sort(vec.begin(), vec.end(), std::greater<>()) : std::sort(vec.begin(), vec.end());
- DebugHandler("sort()");
- update(); // WORKS 2
- }
- // reverse the vector
- private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) {
- std::reverse(vec.begin(), vec.end());
- DebugHandler("reverse()");
- update(); // WORKS 3
- }
- // counts the amount of value form numericUpDown1 in vector
- private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
- int value = std::count(vec.begin(), vec.end(), numericUpDown1->Value);
- DebugHandler("count("+ s(numericUpDown1->Value.ToString()) +") returns "+s(value));
- } // WORKS 4
- // fills vector with value from numericUpDown2
- private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
- std::fill(vec.begin(), vec.end(), decToInt(numericUpDown2->Value));
- DebugHandler("fill("+s(numericUpDown2->Value)+")");
- update(); // WORKS 5
- }
- // delets any duplicates except first object -> to fix
- private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) { // крч numericUpDown возвращает не int, а decimal
- vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
- DebugVector(vec, "vec after unique"); // WORKS 6
- update();
- }
- // swaps elements in vec.at(numericUpDown3) and vec.at(numericUpDown4)
- private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e) {
- if (decToInt(numericUpDown3->Value) < vec.size() && decToInt(numericUpDown4->Value) < vec.size()) {
- std::swap(vec.at(decToInt(numericUpDown3->Value)), vec.at(decToInt(numericUpDown4->Value)));
- DebugVector(vec, "vec after swap");
- update();
- }else { DebugHandler("swap indexes out of range"); } // WORKS 7
- }
- // converts System::Decimal to int32
- int decToInt(const System::Decimal &dec) {
- return dec.ToInt32(dec); // работает, лол
- }
- // оставить комментарии при сдаче))
- private: System::Void button7_Click_1(System::Object^ sender, System::EventArgs^ e) {
- vec.erase(std::remove(vec.begin(), vec.end(), decToInt(numericUpDown5->Value)), vec.end()); // fixed, remove and erase обычно использутся вместе
- DebugHandler("remove(" + s(decToInt(numericUpDown5->Value)) + ")");
- DebugVector(vec, "vec after remove");
- update(); // WORKS 8
- }
- // replaces value 7 to 6
- private: System::Void button8_Click(System::Object^ sender, System::EventArgs^ e) {
- std::replace(vec.begin(), vec.end(), decToInt(numericUpDown7->Value), decToInt(numericUpDown6->Value));
- DebugVector(vec, "vec after repalce");
- update(); //smth like that // WORKS
- }
- //rofl.exe
- private: System::Void button9_Click(System::Object^ sender, System::EventArgs^ e) {
- if (pictureBox1->Visible) {
- pictureBox1->Location = System::Drawing::Point(4000, 5900);
- pictureBox1->Visible = false;
- }
- else {
- pictureBox1->Visible = true;
- pictureBox1->Location = System::Drawing::Point(40, 59);
- }
- }
- // rotates vec around numericUpDown8 first, last, middle
- private: System::Void button10_Click(System::Object^ sender, System::EventArgs^ e) {
- if (vec.size() >= 3 && decToInt(numericUpDown8->Value)<vec.size()) {
- std::rotate(vec.begin(), vec.begin() + decToInt(numericUpDown8->Value), vec.end());
- DebugVector(vec, "vec after rotate");
- update();
- }else { DebugHandler("size()<3 or it.mid>size()"); }
- // WORKS
- } // find value from numericUpDown9 in vec
- private: System::Void button11_Click(System::Object^ sender, System::EventArgs^ e) { // я могу написать функцию,которая будет возвращать индекс, но это дикий костыль, прям пиздец
- int value = std::distance(vec.begin(), std::find(vec.begin(), vec.end(), decToInt(numericUpDown9->Value)));
- (value != vec.size()) ? DebugHandler("find(" + s(numericUpDown9->Value) + ") = " + s(value)) : DebugHandler("not found");
- // WORKS
- } // reverse button for sort
- private: System::Void button12_Click(System::Object^ sender, System::EventArgs^ e) {
- (button2->Text == "reversed sort") ? button2->Text = "sort" : button2->Text = "reversed sort";
- DebugHandler("sort() reverse mode toggled");
- }
- // clears vector
- private: System::Void button13_Click(System::Object^ sender, System::EventArgs^ e) {
- vec.clear();
- update();
- } // clears debug window
- private: System::Void button14_Click(System::Object^ sender, System::EventArgs^ e) {
- listBox1->Items->Clear();
- }
- }; // reverse, sort, count, fill, unique, swap, remove, replace, rotate , find 10/10 algoritmi ahuenni
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement