Advertisement
neongm

Untitled

Nov 7th, 2020
2,179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 29.81 KB | None | 0 0
  1. #pragma once
  2. #include <string>
  3. #include <vector>
  4. #include <msclr\marshal_cppstd.h>
  5. #include <algorithm>
  6. #include <windows.h>
  7.  
  8. namespace lab3OOP {
  9.  
  10.     using namespace System;
  11.     using namespace System::ComponentModel;
  12.     using namespace System::Collections;
  13.     using namespace System::Windows::Forms;
  14.     using namespace System::Data;
  15.     using namespace System::Drawing;
  16.    
  17.     std::vector<int> vec;
  18.     bool reversed_sort;
  19.     /// <summary>
  20.     /// Сводка для MyForm
  21.     /// </summary>
  22.    
  23.     public ref class MyForm : public System::Windows::Forms::Form
  24.     {
  25.     public:
  26.         MyForm(void)
  27.         {
  28.             InitializeComponent();
  29.             //
  30.             //TODO: добавьте код конструктора
  31.             //
  32.         }
  33.  
  34.     protected:
  35.         /// <summary>
  36.         /// Освободить все используемые ресурсы.
  37.         /// </summary>
  38.         ~MyForm()
  39.         {
  40.             if (components)
  41.             {
  42.                 delete components;
  43.             }
  44.         }
  45.     private: System::Windows::Forms::Button^ push_back_button;
  46.     protected:
  47.  
  48.     protected:
  49.     private: System::Windows::Forms::ListBox^ listBox1;
  50.     private: System::Windows::Forms::ListBox^ listBox2;
  51.  
  52.     private: System::Windows::Forms::Button^ genr;
  53.     private: System::Windows::Forms::Button^ button2;
  54.     private: System::Windows::Forms::Button^ button1;
  55.     private: System::Windows::Forms::Button^ button3;
  56.     private: System::Windows::Forms::NumericUpDown^ numericUpDown1;
  57.  
  58.     private: System::Windows::Forms::Button^ button4;
  59.     private: System::Windows::Forms::NumericUpDown^ numericUpDown2;
  60.     private: System::Windows::Forms::Button^ button5;
  61.     private: System::Windows::Forms::NumericUpDown^ numericUpDown3;
  62.     private: System::Windows::Forms::Button^ button6;
  63.     private: System::Windows::Forms::NumericUpDown^ numericUpDown4;
  64.     private: System::Windows::Forms::NumericUpDown^ numericUpDown5;
  65.     private: System::Windows::Forms::Button^ button7;
  66.     private: System::Windows::Forms::NumericUpDown^ numericUpDown6;
  67.     private: System::Windows::Forms::Button^ button8;
  68.     private: System::Windows::Forms::NumericUpDown^ numericUpDown7;
  69.     private: System::Windows::Forms::Button^ button9;
  70.     private: System::Windows::Forms::Button^ button10;
  71.     private: System::Windows::Forms::NumericUpDown^ numericUpDown8;
  72.     private: System::Windows::Forms::Button^ button11;
  73.     private: System::Windows::Forms::NumericUpDown^ numericUpDown9;
  74.     private: System::Windows::Forms::PictureBox^ pictureBox1;
  75.     private: System::Windows::Forms::Button^ button12;
  76.     private: System::Windows::Forms::Button^ button13;
  77.     private: System::Windows::Forms::Button^ button14;
  78.  
  79.  
  80.     private:
  81.         /// <summary>
  82.         /// Обязательная переменная конструктора.
  83.         /// </summary>
  84.         System::ComponentModel::Container^ components;
  85.  
  86. #pragma region Windows Form Designer generated code
  87.         /// <summary>
  88.         /// Требуемый метод для поддержки конструктора — не изменяйте
  89.         /// содержимое этого метода с помощью редактора кода.
  90.         /// </summary>
  91.         void InitializeComponent(void)
  92.         {
  93.             System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(MyForm::typeid));
  94.             this->push_back_button = (gcnew System::Windows::Forms::Button());
  95.             this->listBox1 = (gcnew System::Windows::Forms::ListBox());
  96.             this->listBox2 = (gcnew System::Windows::Forms::ListBox());
  97.             this->genr = (gcnew System::Windows::Forms::Button());
  98.             this->button2 = (gcnew System::Windows::Forms::Button());
  99.             this->button1 = (gcnew System::Windows::Forms::Button());
  100.             this->button3 = (gcnew System::Windows::Forms::Button());
  101.             this->numericUpDown1 = (gcnew System::Windows::Forms::NumericUpDown());
  102.             this->button4 = (gcnew System::Windows::Forms::Button());
  103.             this->numericUpDown2 = (gcnew System::Windows::Forms::NumericUpDown());
  104.             this->button5 = (gcnew System::Windows::Forms::Button());
  105.             this->numericUpDown3 = (gcnew System::Windows::Forms::NumericUpDown());
  106.             this->button6 = (gcnew System::Windows::Forms::Button());
  107.             this->numericUpDown4 = (gcnew System::Windows::Forms::NumericUpDown());
  108.             this->numericUpDown5 = (gcnew System::Windows::Forms::NumericUpDown());
  109.             this->button7 = (gcnew System::Windows::Forms::Button());
  110.             this->numericUpDown6 = (gcnew System::Windows::Forms::NumericUpDown());
  111.             this->button8 = (gcnew System::Windows::Forms::Button());
  112.             this->numericUpDown7 = (gcnew System::Windows::Forms::NumericUpDown());
  113.             this->button9 = (gcnew System::Windows::Forms::Button());
  114.             this->button10 = (gcnew System::Windows::Forms::Button());
  115.             this->numericUpDown8 = (gcnew System::Windows::Forms::NumericUpDown());
  116.             this->button11 = (gcnew System::Windows::Forms::Button());
  117.             this->numericUpDown9 = (gcnew System::Windows::Forms::NumericUpDown());
  118.             this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
  119.             this->button12 = (gcnew System::Windows::Forms::Button());
  120.             this->button13 = (gcnew System::Windows::Forms::Button());
  121.             this->button14 = (gcnew System::Windows::Forms::Button());
  122.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown1))->BeginInit();
  123.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown2))->BeginInit();
  124.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown3))->BeginInit();
  125.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown4))->BeginInit();
  126.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown5))->BeginInit();
  127.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown6))->BeginInit();
  128.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown7))->BeginInit();
  129.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown8))->BeginInit();
  130.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown9))->BeginInit();
  131.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->BeginInit();
  132.             this->SuspendLayout();
  133.             //
  134.             // push_back_button
  135.             //
  136.             this->push_back_button->Cursor = System::Windows::Forms::Cursors::Hand;
  137.             this->push_back_button->Location = System::Drawing::Point(6, 6);
  138.             this->push_back_button->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  139.             this->push_back_button->Name = L"push_back_button";
  140.             this->push_back_button->Size = System::Drawing::Size(173, 33);
  141.             this->push_back_button->TabIndex = 0;
  142.             this->push_back_button->Text = L"push_back random";
  143.             this->push_back_button->UseVisualStyleBackColor = true;
  144.             this->push_back_button->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
  145.             //
  146.             // listBox1
  147.             //
  148.             this->listBox1->FormattingEnabled = true;
  149.             this->listBox1->ItemHeight = 19;
  150.             this->listBox1->Location = System::Drawing::Point(353, 48);
  151.             this->listBox1->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  152.             this->listBox1->Name = L"listBox1";
  153.             this->listBox1->Size = System::Drawing::Size(178, 460);
  154.             this->listBox1->TabIndex = 1;
  155.             //
  156.             // listBox2
  157.             //
  158.             this->listBox2->FormattingEnabled = true;
  159.             this->listBox2->ItemHeight = 19;
  160.             this->listBox2->Location = System::Drawing::Point(6, 48);
  161.             this->listBox2->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  162.             this->listBox2->Name = L"listBox2";
  163.             this->listBox2->Size = System::Drawing::Size(173, 460);
  164.             this->listBox2->TabIndex = 2;
  165.             //
  166.             // genr
  167.             //
  168.             this->genr->Cursor = System::Windows::Forms::Cursors::Hand;
  169.             this->genr->Location = System::Drawing::Point(186, 48);
  170.             this->genr->Margin = System::Windows::Forms::Padding(1);
  171.             this->genr->Name = L"genr";
  172.             this->genr->Size = System::Drawing::Size(162, 33);
  173.             this->genr->TabIndex = 4;
  174.             this->genr->Text = L"size";
  175.             this->genr->UseVisualStyleBackColor = true;
  176.             this->genr->Click += gcnew System::EventHandler(this, &MyForm::genr_Click);
  177.             //
  178.             // button2
  179.             //
  180.             this->button2->Cursor = System::Windows::Forms::Cursors::Hand;
  181.             this->button2->Location = System::Drawing::Point(186, 85);
  182.             this->button2->Name = L"button2";
  183.             this->button2->Size = System::Drawing::Size(117, 33);
  184.             this->button2->TabIndex = 5;
  185.             this->button2->Text = L"sort";
  186.             this->button2->UseVisualStyleBackColor = true;
  187.             this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
  188.             //
  189.             // button1
  190.             //
  191.             this->button1->Cursor = System::Windows::Forms::Cursors::Hand;
  192.             this->button1->Location = System::Drawing::Point(186, 124);
  193.             this->button1->Name = L"button1";
  194.             this->button1->Size = System::Drawing::Size(162, 33);
  195.             this->button1->TabIndex = 6;
  196.             this->button1->Text = L"reverse";
  197.             this->button1->UseVisualStyleBackColor = true;
  198.             this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click_1);
  199.             //
  200.             // button3
  201.             //
  202.             this->button3->Cursor = System::Windows::Forms::Cursors::Hand;
  203.             this->button3->Location = System::Drawing::Point(186, 163);
  204.             this->button3->Name = L"button3";
  205.             this->button3->Size = System::Drawing::Size(117, 33);
  206.             this->button3->TabIndex = 7;
  207.             this->button3->Text = L"count";
  208.             this->button3->UseVisualStyleBackColor = true;
  209.             this->button3->Click += gcnew System::EventHandler(this, &MyForm::button3_Click);
  210.             //
  211.             // numericUpDown1
  212.             //
  213.             this->numericUpDown1->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
  214.             this->numericUpDown1->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 13.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  215.                 static_cast<System::Byte>(204)));
  216.             this->numericUpDown1->Location = System::Drawing::Point(309, 163);
  217.             this->numericUpDown1->Name = L"numericUpDown1";
  218.             this->numericUpDown1->Size = System::Drawing::Size(38, 31);
  219.             this->numericUpDown1->TabIndex = 8;
  220.             //
  221.             // button4
  222.             //
  223.             this->button4->Cursor = System::Windows::Forms::Cursors::Hand;
  224.             this->button4->Location = System::Drawing::Point(186, 202);
  225.             this->button4->Name = L"button4";
  226.             this->button4->Size = System::Drawing::Size(117, 33);
  227.             this->button4->TabIndex = 10;
  228.             this->button4->Text = L"fill";
  229.             this->button4->UseVisualStyleBackColor = true;
  230.             this->button4->Click += gcnew System::EventHandler(this, &MyForm::button4_Click);
  231.             //
  232.             // numericUpDown2
  233.             //
  234.             this->numericUpDown2->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
  235.             this->numericUpDown2->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 13.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  236.                 static_cast<System::Byte>(204)));
  237.             this->numericUpDown2->Location = System::Drawing::Point(310, 202);
  238.             this->numericUpDown2->Name = L"numericUpDown2";
  239.             this->numericUpDown2->Size = System::Drawing::Size(38, 31);
  240.             this->numericUpDown2->TabIndex = 11;
  241.             //
  242.             // button5
  243.             //
  244.             this->button5->Cursor = System::Windows::Forms::Cursors::Hand;
  245.             this->button5->Location = System::Drawing::Point(186, 241);
  246.             this->button5->Name = L"button5";
  247.             this->button5->Size = System::Drawing::Size(162, 33);
  248.             this->button5->TabIndex = 12;
  249.             this->button5->Text = L"unique";
  250.             this->button5->UseVisualStyleBackColor = true;
  251.             this->button5->Click += gcnew System::EventHandler(this, &MyForm::button5_Click);
  252.             //
  253.             // numericUpDown3
  254.             //
  255.             this->numericUpDown3->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 13.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  256.                 static_cast<System::Byte>(204)));
  257.             this->numericUpDown3->Location = System::Drawing::Point(186, 280);
  258.             this->numericUpDown3->Name = L"numericUpDown3";
  259.             this->numericUpDown3->Size = System::Drawing::Size(39, 31);
  260.             this->numericUpDown3->TabIndex = 13;
  261.             //
  262.             // button6
  263.             //
  264.             this->button6->Cursor = System::Windows::Forms::Cursors::Hand;
  265.             this->button6->Location = System::Drawing::Point(231, 280);
  266.             this->button6->Name = L"button6";
  267.             this->button6->Size = System::Drawing::Size(72, 33);
  268.             this->button6->TabIndex = 14;
  269.             this->button6->Text = L"swap";
  270.             this->button6->UseVisualStyleBackColor = true;
  271.             this->button6->Click += gcnew System::EventHandler(this, &MyForm::button6_Click);
  272.             //
  273.             // numericUpDown4
  274.             //
  275.             this->numericUpDown4->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
  276.             this->numericUpDown4->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 13.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  277.                 static_cast<System::Byte>(204)));
  278.             this->numericUpDown4->Location = System::Drawing::Point(310, 280);
  279.             this->numericUpDown4->Name = L"numericUpDown4";
  280.             this->numericUpDown4->Size = System::Drawing::Size(38, 31);
  281.             this->numericUpDown4->TabIndex = 15;
  282.             //
  283.             // numericUpDown5
  284.             //
  285.             this->numericUpDown5->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
  286.             this->numericUpDown5->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 13.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  287.                 static_cast<System::Byte>(204)));
  288.             this->numericUpDown5->Location = System::Drawing::Point(310, 317);
  289.             this->numericUpDown5->Name = L"numericUpDown5";
  290.             this->numericUpDown5->Size = System::Drawing::Size(38, 31);
  291.             this->numericUpDown5->TabIndex = 16;
  292.             //
  293.             // button7
  294.             //
  295.             this->button7->Cursor = System::Windows::Forms::Cursors::Hand;
  296.             this->button7->Location = System::Drawing::Point(186, 317);
  297.             this->button7->Name = L"button7";
  298.             this->button7->Size = System::Drawing::Size(118, 33);
  299.             this->button7->TabIndex = 17;
  300.             this->button7->Text = L"remove";
  301.             this->button7->UseVisualStyleBackColor = true;
  302.             this->button7->Click += gcnew System::EventHandler(this, &MyForm::button7_Click_1);
  303.             //
  304.             // numericUpDown6
  305.             //
  306.             this->numericUpDown6->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
  307.             this->numericUpDown6->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 13.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  308.                 static_cast<System::Byte>(204)));
  309.             this->numericUpDown6->Location = System::Drawing::Point(310, 354);
  310.             this->numericUpDown6->Name = L"numericUpDown6";
  311.             this->numericUpDown6->Size = System::Drawing::Size(38, 31);
  312.             this->numericUpDown6->TabIndex = 20;
  313.             //
  314.             // button8
  315.             //
  316.             this->button8->Cursor = System::Windows::Forms::Cursors::Hand;
  317.             this->button8->Location = System::Drawing::Point(232, 356);
  318.             this->button8->Name = L"button8";
  319.             this->button8->Size = System::Drawing::Size(72, 33);
  320.             this->button8->TabIndex = 19;
  321.             this->button8->Text = L"replace";
  322.             this->button8->UseVisualStyleBackColor = true;
  323.             this->button8->Click += gcnew System::EventHandler(this, &MyForm::button8_Click);
  324.             //
  325.             // numericUpDown7
  326.             //
  327.             this->numericUpDown7->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 13.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  328.                 static_cast<System::Byte>(204)));
  329.             this->numericUpDown7->Location = System::Drawing::Point(186, 356);
  330.             this->numericUpDown7->Name = L"numericUpDown7";
  331.             this->numericUpDown7->Size = System::Drawing::Size(38, 31);
  332.             this->numericUpDown7->TabIndex = 18;
  333.             //
  334.             // button9
  335.             //
  336.             this->button9->Cursor = System::Windows::Forms::Cursors::Hand;
  337.             this->button9->Location = System::Drawing::Point(187, 469);
  338.             this->button9->Name = L"button9";
  339.             this->button9->Size = System::Drawing::Size(162, 39);
  340.             this->button9->TabIndex = 21;
  341.             this->button9->Text = L"woof";
  342.             this->button9->UseVisualStyleBackColor = true;
  343.             this->button9->Click += gcnew System::EventHandler(this, &MyForm::button9_Click);
  344.             //
  345.             // button10
  346.             //
  347.             this->button10->Cursor = System::Windows::Forms::Cursors::Hand;
  348.             this->button10->Location = System::Drawing::Point(186, 393);
  349.             this->button10->Name = L"button10";
  350.             this->button10->Size = System::Drawing::Size(118, 33);
  351.             this->button10->TabIndex = 22;
  352.             this->button10->Text = L"rotate";
  353.             this->button10->UseVisualStyleBackColor = true;
  354.             this->button10->Click += gcnew System::EventHandler(this, &MyForm::button10_Click);
  355.             //
  356.             // numericUpDown8
  357.             //
  358.             this->numericUpDown8->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
  359.             this->numericUpDown8->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 13.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  360.                 static_cast<System::Byte>(204)));
  361.             this->numericUpDown8->Location = System::Drawing::Point(310, 395);
  362.             this->numericUpDown8->Name = L"numericUpDown8";
  363.             this->numericUpDown8->Size = System::Drawing::Size(38, 31);
  364.             this->numericUpDown8->TabIndex = 23;
  365.             //
  366.             // button11
  367.             //
  368.             this->button11->Cursor = System::Windows::Forms::Cursors::Hand;
  369.             this->button11->Location = System::Drawing::Point(187, 432);
  370.             this->button11->Name = L"button11";
  371.             this->button11->Size = System::Drawing::Size(117, 33);
  372.             this->button11->TabIndex = 24;
  373.             this->button11->Text = L"find";
  374.             this->button11->UseVisualStyleBackColor = true;
  375.             this->button11->Click += gcnew System::EventHandler(this, &MyForm::button11_Click);
  376.             //
  377.             // numericUpDown9
  378.             //
  379.             this->numericUpDown9->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
  380.             this->numericUpDown9->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 13.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  381.                 static_cast<System::Byte>(204)));
  382.             this->numericUpDown9->Location = System::Drawing::Point(310, 432);
  383.             this->numericUpDown9->Name = L"numericUpDown9";
  384.             this->numericUpDown9->Size = System::Drawing::Size(38, 31);
  385.             this->numericUpDown9->TabIndex = 25;
  386.             //
  387.             // pictureBox1
  388.             //
  389.             this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox1.Image")));
  390.             this->pictureBox1->Location = System::Drawing::Point(418, 1750);
  391.             this->pictureBox1->Name = L"pictureBox1";
  392.             this->pictureBox1->Size = System::Drawing::Size(480, 273);
  393.             this->pictureBox1->SizeMode = System::Windows::Forms::PictureBoxSizeMode::StretchImage;
  394.             this->pictureBox1->TabIndex = 26;
  395.             this->pictureBox1->TabStop = false;
  396.             this->pictureBox1->Visible = false;
  397.             //
  398.             // button12
  399.             //
  400.             this->button12->Cursor = System::Windows::Forms::Cursors::Hand;
  401.             this->button12->Location = System::Drawing::Point(309, 85);
  402.             this->button12->Name = L"button12";
  403.             this->button12->Size = System::Drawing::Size(39, 33);
  404.             this->button12->TabIndex = 27;
  405.             this->button12->Text = L"R";
  406.             this->button12->UseVisualStyleBackColor = true;
  407.             this->button12->Click += gcnew System::EventHandler(this, &MyForm::button12_Click);
  408.             //
  409.             // button13
  410.             //
  411.             this->button13->Cursor = System::Windows::Forms::Cursors::Hand;
  412.             this->button13->Location = System::Drawing::Point(186, 6);
  413.             this->button13->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  414.             this->button13->Name = L"button13";
  415.             this->button13->Size = System::Drawing::Size(63, 33);
  416.             this->button13->TabIndex = 28;
  417.             this->button13->Text = L"сlear";
  418.             this->button13->UseVisualStyleBackColor = true;
  419.             this->button13->Click += gcnew System::EventHandler(this, &MyForm::button13_Click);
  420.             //
  421.             // button14
  422.             //
  423.             this->button14->Cursor = System::Windows::Forms::Cursors::Hand;
  424.             this->button14->Location = System::Drawing::Point(353, 6);
  425.             this->button14->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  426.             this->button14->Name = L"button14";
  427.             this->button14->Size = System::Drawing::Size(178, 33);
  428.             this->button14->TabIndex = 29;
  429.             this->button14->Text = L"clear debug values";
  430.             this->button14->UseVisualStyleBackColor = true;
  431.             this->button14->Click += gcnew System::EventHandler(this, &MyForm::button14_Click);
  432.             //
  433.             // MyForm
  434.             //
  435.             this->AutoScaleDimensions = System::Drawing::SizeF(7, 19);
  436.             this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  437.             this->ClientSize = System::Drawing::Size(537, 514);
  438.             this->Controls->Add(this->button14);
  439.             this->Controls->Add(this->button13);
  440.             this->Controls->Add(this->pictureBox1);
  441.             this->Controls->Add(this->button12);
  442.             this->Controls->Add(this->numericUpDown9);
  443.             this->Controls->Add(this->button11);
  444.             this->Controls->Add(this->numericUpDown8);
  445.             this->Controls->Add(this->button10);
  446.             this->Controls->Add(this->button9);
  447.             this->Controls->Add(this->numericUpDown6);
  448.             this->Controls->Add(this->button8);
  449.             this->Controls->Add(this->numericUpDown7);
  450.             this->Controls->Add(this->button7);
  451.             this->Controls->Add(this->numericUpDown5);
  452.             this->Controls->Add(this->numericUpDown4);
  453.             this->Controls->Add(this->button6);
  454.             this->Controls->Add(this->numericUpDown3);
  455.             this->Controls->Add(this->button5);
  456.             this->Controls->Add(this->numericUpDown2);
  457.             this->Controls->Add(this->button4);
  458.             this->Controls->Add(this->numericUpDown1);
  459.             this->Controls->Add(this->button3);
  460.             this->Controls->Add(this->button1);
  461.             this->Controls->Add(this->button2);
  462.             this->Controls->Add(this->genr);
  463.             this->Controls->Add(this->listBox2);
  464.             this->Controls->Add(this->listBox1);
  465.             this->Controls->Add(this->push_back_button);
  466.             this->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei Light", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  467.                 static_cast<System::Byte>(204)));
  468.             this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle;
  469.             this->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  470.             this->MaximizeBox = false;
  471.             this->Name = L"MyForm";
  472.             this->Text = L"MyForm";
  473.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown1))->EndInit();
  474.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown2))->EndInit();
  475.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown3))->EndInit();
  476.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown4))->EndInit();
  477.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown5))->EndInit();
  478.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown6))->EndInit();
  479.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown7))->EndInit();
  480.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown8))->EndInit();
  481.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown9))->EndInit();
  482.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->EndInit();
  483.             this->ResumeLayout(false);
  484.  
  485.         }
  486. #pragma endregion
  487.  
  488.         int Random(const int& min, const int& max) {
  489.             return min + std::rand() % (max - min + 1);
  490.         }
  491.         void DebugHandler(std::string message) {
  492.             listBox1->Items->Insert(listBox1->Items->Count, cs(message));
  493.         }void DebugHandler(String^ message) {
  494.             listBox1->Items->Insert(listBox1->Items->Count, message);
  495.         }
  496.         template<typename T>
  497.         void DebugVector(std::vector<T> vec, std::string message) {
  498.             listBox1->Items->Insert(listBox1->Items->Count, cs(message + " ["));
  499.             for (size_t i = 0; i < vec.size(); i++) listBox1->Items->Insert(listBox1->Items->Count, cs("    " + s(vec.at(i))));
  500.             listBox1->Items->Insert(listBox1->Items->Count, cs("]"));
  501.         }
  502.         // converts System::String to std::string
  503.         std::string s(String^ str) {
  504.             return msclr::interop::marshal_as<std::string>(str);
  505.         }std::string s(System::Decimal dec) {
  506.             return std::to_string(decToInt(dec));
  507.         }template<typename T>
  508.             std::string s(const T& value) {  // converts ints, floats and anything it can to std::string
  509.             return std::to_string(value);
  510.         }
  511.         // converts std::string to System::String^
  512.         System::String^ cs(std::string str) {
  513.             return gcnew String(str.c_str());
  514.         }
  515.         // the main update function to refresh the vector in listbox
  516.         void update() {
  517.             listBox2->Items->Clear();
  518.             for (size_t i = 0; i < vec.size(); i++)
  519.                 listBox2->Items->Insert(listBox2->Items->Count, cs(s(vec.at(i))));
  520.         }                                                                      // WORKS 1
  521.         // adds random number to the vector
  522. private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
  523.         vec.push_back(Random(0, 10));
  524.         update();
  525.     }
  526.        // generate(), -> replace with something working in CLR
  527. private: System::Void genr_Click(System::Object^ sender, System::EventArgs^ e) {
  528.         DebugHandler("size() returns " + s(size(vec)));
  529.     }                                                                          // NEEDS REPLACE
  530.        // basicly sort, -> added the reverse sort checkbox
  531. private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
  532.         (button2->Text=="reversed sort") ? std::sort(vec.begin(), vec.end(), std::greater<>()) : std::sort(vec.begin(), vec.end());
  533.         DebugHandler("sort()");
  534.         update();                                                              // WORKS 2
  535.     }
  536.        // reverse the vector
  537. private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) {
  538.         std::reverse(vec.begin(), vec.end());
  539.         DebugHandler("reverse()");
  540.         update();                                                              // WORKS 3
  541.     }
  542.        // counts the amount of value form numericUpDown1 in vector
  543. private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
  544.         int value = std::count(vec.begin(), vec.end(), numericUpDown1->Value);
  545.         DebugHandler("count("+ s(numericUpDown1->Value.ToString()) +") returns "+s(value));
  546.     }                                                                           // WORKS 4
  547.        // fills vector with value from numericUpDown2
  548. private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
  549.         std::fill(vec.begin(), vec.end(), decToInt(numericUpDown2->Value));
  550.         DebugHandler("fill("+s(numericUpDown2->Value)+")");
  551.         update();                                                               // WORKS 5
  552.     }
  553.        // delets any duplicates except first object  -> to fix
  554. private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) {       // крч numericUpDown возвращает не int, а decimal
  555.         vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
  556.         DebugVector(vec, "vec after unique");                                   // WORKS 6
  557.         update();              
  558.     }
  559.        // swaps elements in vec.at(numericUpDown3) and vec.at(numericUpDown4)
  560. private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e) {
  561.         if (decToInt(numericUpDown3->Value) < vec.size() && decToInt(numericUpDown4->Value) < vec.size()) {
  562.             std::swap(vec.at(decToInt(numericUpDown3->Value)), vec.at(decToInt(numericUpDown4->Value)));
  563.             DebugVector(vec, "vec after swap");
  564.             update();
  565.         }else { DebugHandler("swap indexes out of range"); }                    // WORKS 7
  566.     }
  567.  
  568.        // converts System::Decimal to int32
  569.        int decToInt(const System::Decimal &dec) {
  570.            return dec.ToInt32(dec); // работает, лол
  571.        }
  572.        // оставить комментарии при сдаче))
  573.  
  574. private: System::Void button7_Click_1(System::Object^ sender, System::EventArgs^ e) {
  575.         vec.erase(std::remove(vec.begin(), vec.end(), decToInt(numericUpDown5->Value)), vec.end());  // fixed, remove and erase обычно использутся вместе
  576.         DebugHandler("remove(" + s(decToInt(numericUpDown5->Value)) + ")");
  577.         DebugVector(vec, "vec after remove");  
  578.         update();                                                                // WORKS 8
  579. }
  580.        // replaces value 7 to 6
  581.     private: System::Void button8_Click(System::Object^ sender, System::EventArgs^ e) {
  582.         std::replace(vec.begin(), vec.end(), decToInt(numericUpDown7->Value), decToInt(numericUpDown6->Value));  
  583.         DebugVector(vec, "vec after repalce");
  584.         update(); //smth like that                                               // WORKS
  585.     }
  586.        //rofl.exe
  587. private: System::Void button9_Click(System::Object^ sender, System::EventArgs^ e) {
  588.     if (pictureBox1->Visible) {
  589.         pictureBox1->Location = System::Drawing::Point(4000, 5900);
  590.         pictureBox1->Visible = false;
  591.     }
  592.     else {
  593.         pictureBox1->Visible = true;
  594.         pictureBox1->Location = System::Drawing::Point(40, 59);
  595.     }
  596. }
  597.        // rotates vec around numericUpDown8  first, last, middle
  598. private: System::Void button10_Click(System::Object^ sender, System::EventArgs^ e) {
  599.         if (vec.size() >= 3 && decToInt(numericUpDown8->Value)<vec.size()) {
  600.             std::rotate(vec.begin(), vec.begin() + decToInt(numericUpDown8->Value), vec.end());
  601.             DebugVector(vec, "vec after rotate");
  602.             update();
  603.         }else { DebugHandler("size()<3 or it.mid>size()"); }
  604.                                                                                 // WORKS
  605.  
  606. }      // find value from numericUpDown9 in vec
  607.  private: System::Void button11_Click(System::Object^ sender, System::EventArgs^ e) {  // я могу написать функцию,которая будет возвращать индекс, но это дикий костыль, прям пиздец
  608.      int value = std::distance(vec.begin(), std::find(vec.begin(), vec.end(), decToInt(numericUpDown9->Value)));
  609.      (value != vec.size()) ? DebugHandler("find(" + s(numericUpDown9->Value) + ") = " + s(value)) : DebugHandler("not found");
  610.                                                                                  // WORKS
  611. }      // reverse button for sort
  612. private: System::Void button12_Click(System::Object^ sender, System::EventArgs^ e) {
  613.     (button2->Text == "reversed sort") ?  button2->Text = "sort" : button2->Text = "reversed sort";
  614.     DebugHandler("sort() reverse mode toggled");
  615. }
  616.        // clears vector
  617. private: System::Void button13_Click(System::Object^ sender, System::EventArgs^ e) {
  618.     vec.clear();
  619.     update();
  620. }      // clears debug window
  621. private: System::Void button14_Click(System::Object^ sender, System::EventArgs^ e) {
  622.     listBox1->Items->Clear();
  623. }
  624. };        // reverse, sort, count, fill, unique, swap, remove, replace, rotate , find          10/10 algoritmi ahuenni
  625. }
  626.  
  627.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement