4DM3M

Solution.h

Jan 7th, 2021
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.23 KB | None | 0 0
  1. #pragma once   
  2.  
  3. namespace LR2813 {
  4.  
  5.     using namespace System;
  6.     using namespace System::ComponentModel;
  7.     using namespace System::Collections;
  8.     using namespace System::Windows::Forms;
  9.     using namespace System::Data;
  10.     using namespace System::Drawing;
  11.  
  12.     /// <summary>
  13.     /// Сводка для Real
  14.     /// </summary>
  15.     public ref class Real : public System::Windows::Forms::Form
  16.     {
  17.     public:
  18.         Real(void)
  19.         {
  20.             InitializeComponent();
  21.             //
  22.             //TODO: добавьте код конструктора
  23.             //
  24.         }
  25.  
  26.     protected:
  27.         /// <summary>
  28.         /// Освободить все используемые ресурсы.
  29.         /// </summary>
  30.         ~Real()
  31.         {
  32.             if (components)
  33.             {
  34.                 delete components;
  35.             }
  36.         }
  37.     private: System::Windows::Forms::Button^ Menu;
  38.     private: System::Windows::Forms::DataGridView^ GridTable;
  39.     private: System::Windows::Forms::ComboBox^ comboBox1;
  40.     private: System::Windows::Forms::Button^ ButtonReady;
  41.     protected:
  42.  
  43.     private:
  44.         /// <summary>
  45.         /// Обязательная переменная конструктора.
  46.         /// </summary>
  47.         System::ComponentModel::Container^ components;
  48.  
  49. #pragma region Windows Form Designer generated code
  50.         /// <summary>
  51.         /// Требуемый метод для поддержки конструктора — не изменяйте
  52.         /// содержимое этого метода с помощью редактора кода.
  53.         /// </summary>
  54.         void InitializeComponent(void)
  55.         {
  56.             System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle1 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
  57.             this->Menu = (gcnew System::Windows::Forms::Button());
  58.             this->GridTable = (gcnew System::Windows::Forms::DataGridView());
  59.             this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
  60.             this->ButtonReady = (gcnew System::Windows::Forms::Button());
  61.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->GridTable))->BeginInit();
  62.             this->SuspendLayout();
  63.             //
  64.             // Menu
  65.             //
  66.             this->Menu->Location = System::Drawing::Point(12, 12);
  67.             this->Menu->Name = L"Menu";
  68.             this->Menu->Size = System::Drawing::Size(96, 36);
  69.             this->Menu->TabIndex = 0;
  70.             this->Menu->Text = L"Назад";
  71.             this->Menu->UseVisualStyleBackColor = true;
  72.             this->Menu->Click += gcnew System::EventHandler(this, &Real::Menu_Click);
  73.             //
  74.             // GridTable
  75.             //
  76.             this->GridTable->AutoSizeColumnsMode = System::Windows::Forms::DataGridViewAutoSizeColumnsMode::Fill;
  77.             this->GridTable->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
  78.             this->GridTable->ColumnHeadersVisible = false;
  79.             dataGridViewCellStyle1->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleLeft;
  80.             dataGridViewCellStyle1->BackColor = System::Drawing::SystemColors::Window;
  81.             dataGridViewCellStyle1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  82.                 static_cast<System::Byte>(204)));
  83.             dataGridViewCellStyle1->ForeColor = System::Drawing::SystemColors::ControlText;
  84.             dataGridViewCellStyle1->SelectionBackColor = System::Drawing::SystemColors::Highlight;
  85.             dataGridViewCellStyle1->SelectionForeColor = System::Drawing::SystemColors::HighlightText;
  86.             dataGridViewCellStyle1->WrapMode = System::Windows::Forms::DataGridViewTriState::False;
  87.             this->GridTable->DefaultCellStyle = dataGridViewCellStyle1;
  88.             this->GridTable->Location = System::Drawing::Point(12, 378);
  89.             this->GridTable->Name = L"GridTable";
  90.             this->GridTable->RowHeadersVisible = false;
  91.             this->GridTable->RowHeadersWidth = 51;
  92.             this->GridTable->RowTemplate->Height = 55;
  93.             this->GridTable->Size = System::Drawing::Size(537, 91);
  94.             this->GridTable->TabIndex = 1;
  95.             //
  96.             // comboBox1
  97.             //
  98.             this->comboBox1->FormattingEnabled = true;
  99.             this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^  >(10) {
  100.                 L"1", L"2", L"3", L"4", L"5", L"6", L"7", L"8",
  101.                     L"9", L"10"
  102.             });
  103.             this->comboBox1->Location = System::Drawing::Point(428, 24);
  104.             this->comboBox1->Name = L"comboBox1";
  105.             this->comboBox1->Size = System::Drawing::Size(121, 24);
  106.             this->comboBox1->TabIndex = 2;
  107.             this->comboBox1->Text = L"Размерность";
  108.             this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &Real::comboBox1_SelectedIndexChanged);
  109.             //
  110.             // ButtonReady
  111.             //
  112.             this->ButtonReady->Location = System::Drawing::Point(453, 336);
  113.             this->ButtonReady->Name = L"ButtonReady";
  114.             this->ButtonReady->Size = System::Drawing::Size(96, 36);
  115.             this->ButtonReady->TabIndex = 3;
  116.             this->ButtonReady->Text = L"Готово";
  117.             this->ButtonReady->UseVisualStyleBackColor = true;
  118.             this->ButtonReady->Click += gcnew System::EventHandler(this, &Real::ButtonReady_Click);
  119.             //
  120.             // Real
  121.             //
  122.             this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
  123.             this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  124.             this->BackColor = System::Drawing::SystemColors::ControlDarkDark;
  125.             this->ClientSize = System::Drawing::Size(561, 481);
  126.             this->Controls->Add(this->ButtonReady);
  127.             this->Controls->Add(this->comboBox1);
  128.             this->Controls->Add(this->GridTable);
  129.             this->Controls->Add(this->Menu);
  130.             this->Name = L"Real";
  131.             this->Text = L"Реализация";
  132.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->GridTable))->EndInit();
  133.             this->ResumeLayout(false);
  134.  
  135.         }
  136. #pragma endregion
  137.     private: System::Void Menu_Click(System::Object^ sender, System::EventArgs^ e) {
  138.         Owner->Show();
  139.         this->Close();
  140.     }
  141.     private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
  142.         if (comboBox1->SelectedItem == "1") {
  143.             GridTable->ColumnCount = 1;
  144.  
  145.         }
  146.         else if (comboBox1->SelectedItem == "2") {
  147.             GridTable->ColumnCount = 2;
  148.         }
  149.         else if (comboBox1->SelectedItem == "3") {
  150.             GridTable->ColumnCount = 3;
  151.  
  152.         }
  153.         else if (comboBox1->SelectedItem == "4") {
  154.             GridTable->ColumnCount = 4;
  155.  
  156.         }
  157.         else if (comboBox1->SelectedItem == "5") {
  158.             GridTable->ColumnCount = 5;
  159.  
  160.         }
  161.         else if (comboBox1->SelectedItem == "6") {
  162.             GridTable->ColumnCount = 6;
  163.  
  164.         }
  165.         else if (comboBox1->SelectedItem == "7") {
  166.             GridTable->ColumnCount = 7;
  167.  
  168.         }
  169.         else if (comboBox1->SelectedItem == "8") {
  170.             GridTable->ColumnCount = 8;
  171.  
  172.         }
  173.         else if (comboBox1->SelectedItem == "9") {
  174.             GridTable->ColumnCount = 9;
  175.  
  176.         }
  177.         else if (comboBox1->SelectedItem == "10") {
  178.             GridTable->ColumnCount = 10;
  179.  
  180.         }
  181.         GridTable->ColumnHeadersVisible = true;
  182.         for (int i = 0; i < GridTable->ColumnCount; i++)
  183.         {
  184.             GridTable->Columns[i]->HeaderCell->Value = Convert::ToString(i + 1);
  185.         }
  186.  
  187.     }
  188.  
  189.  
  190.     private: System::Void ButtonReady_Click(System::Object^ sender, System::EventArgs^ e) {
  191.         using namespace std;
  192.         int n, i, a[100];
  193.         n = GridTable->ColumnCount;
  194.         for (i = 0; i < n; i++)
  195.             a[i] = Convert::ToInt16(GridTable[i, 0]->Value);
  196.  
  197.         int max, nom;
  198.  
  199.         for (int i = 0; i < n - 1; i++)
  200.         {
  201.             max = a[i]; nom = i;
  202.             for (int j = i + 1; j < n; j++)
  203.                 if (a[j] < max)
  204.                 {
  205.                     max = a[j];
  206.                     nom = j;
  207.                 }
  208.             a[nom] = a[i];
  209.             a[i] = max;
  210.  
  211.         }
  212.             for (int i = 0; i < n; i++)
  213.                 GridTable[i, 0]->Value = Convert::ToString(a[i]);
  214.     };
  215. };
  216. }
Advertisement
Add Comment
Please, Sign In to add comment