Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- namespace LR2813 {
- using namespace System;
- using namespace System::ComponentModel;
- using namespace System::Collections;
- using namespace System::Windows::Forms;
- using namespace System::Data;
- using namespace System::Drawing;
- /// <summary>
- /// Сводка для Real
- /// </summary>
- public ref class Real : public System::Windows::Forms::Form
- {
- public:
- Real(void)
- {
- InitializeComponent();
- //
- //TODO: добавьте код конструктора
- //
- }
- protected:
- /// <summary>
- /// Освободить все используемые ресурсы.
- /// </summary>
- ~Real()
- {
- if (components)
- {
- delete components;
- }
- }
- private: System::Windows::Forms::Button^ Menu;
- private: System::Windows::Forms::DataGridView^ GridTable;
- private: System::Windows::Forms::ComboBox^ comboBox1;
- private: System::Windows::Forms::Button^ ButtonReady;
- protected:
- private:
- /// <summary>
- /// Обязательная переменная конструктора.
- /// </summary>
- System::ComponentModel::Container^ components;
- #pragma region Windows Form Designer generated code
- /// <summary>
- /// Требуемый метод для поддержки конструктора — не изменяйте
- /// содержимое этого метода с помощью редактора кода.
- /// </summary>
- void InitializeComponent(void)
- {
- System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle1 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
- this->Menu = (gcnew System::Windows::Forms::Button());
- this->GridTable = (gcnew System::Windows::Forms::DataGridView());
- this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
- this->ButtonReady = (gcnew System::Windows::Forms::Button());
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->GridTable))->BeginInit();
- this->SuspendLayout();
- //
- // Menu
- //
- this->Menu->Location = System::Drawing::Point(12, 12);
- this->Menu->Name = L"Menu";
- this->Menu->Size = System::Drawing::Size(96, 36);
- this->Menu->TabIndex = 0;
- this->Menu->Text = L"Назад";
- this->Menu->UseVisualStyleBackColor = true;
- this->Menu->Click += gcnew System::EventHandler(this, &Real::Menu_Click);
- //
- // GridTable
- //
- this->GridTable->AutoSizeColumnsMode = System::Windows::Forms::DataGridViewAutoSizeColumnsMode::Fill;
- this->GridTable->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
- this->GridTable->ColumnHeadersVisible = false;
- dataGridViewCellStyle1->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleLeft;
- dataGridViewCellStyle1->BackColor = System::Drawing::SystemColors::Window;
- dataGridViewCellStyle1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(204)));
- dataGridViewCellStyle1->ForeColor = System::Drawing::SystemColors::ControlText;
- dataGridViewCellStyle1->SelectionBackColor = System::Drawing::SystemColors::Highlight;
- dataGridViewCellStyle1->SelectionForeColor = System::Drawing::SystemColors::HighlightText;
- dataGridViewCellStyle1->WrapMode = System::Windows::Forms::DataGridViewTriState::False;
- this->GridTable->DefaultCellStyle = dataGridViewCellStyle1;
- this->GridTable->Location = System::Drawing::Point(12, 378);
- this->GridTable->Name = L"GridTable";
- this->GridTable->RowHeadersVisible = false;
- this->GridTable->RowHeadersWidth = 51;
- this->GridTable->RowTemplate->Height = 55;
- this->GridTable->Size = System::Drawing::Size(537, 91);
- this->GridTable->TabIndex = 1;
- //
- // comboBox1
- //
- this->comboBox1->FormattingEnabled = true;
- this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^ >(10) {
- L"1", L"2", L"3", L"4", L"5", L"6", L"7", L"8",
- L"9", L"10"
- });
- this->comboBox1->Location = System::Drawing::Point(428, 24);
- this->comboBox1->Name = L"comboBox1";
- this->comboBox1->Size = System::Drawing::Size(121, 24);
- this->comboBox1->TabIndex = 2;
- this->comboBox1->Text = L"Размерность";
- this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &Real::comboBox1_SelectedIndexChanged);
- //
- // ButtonReady
- //
- this->ButtonReady->Location = System::Drawing::Point(453, 336);
- this->ButtonReady->Name = L"ButtonReady";
- this->ButtonReady->Size = System::Drawing::Size(96, 36);
- this->ButtonReady->TabIndex = 3;
- this->ButtonReady->Text = L"Готово";
- this->ButtonReady->UseVisualStyleBackColor = true;
- this->ButtonReady->Click += gcnew System::EventHandler(this, &Real::ButtonReady_Click);
- //
- // Real
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->BackColor = System::Drawing::SystemColors::ControlDarkDark;
- this->ClientSize = System::Drawing::Size(561, 481);
- this->Controls->Add(this->ButtonReady);
- this->Controls->Add(this->comboBox1);
- this->Controls->Add(this->GridTable);
- this->Controls->Add(this->Menu);
- this->Name = L"Real";
- this->Text = L"Реализация";
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->GridTable))->EndInit();
- this->ResumeLayout(false);
- }
- #pragma endregion
- private: System::Void Menu_Click(System::Object^ sender, System::EventArgs^ e) {
- Owner->Show();
- this->Close();
- }
- private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
- if (comboBox1->SelectedItem == "1") {
- GridTable->ColumnCount = 1;
- }
- else if (comboBox1->SelectedItem == "2") {
- GridTable->ColumnCount = 2;
- }
- else if (comboBox1->SelectedItem == "3") {
- GridTable->ColumnCount = 3;
- }
- else if (comboBox1->SelectedItem == "4") {
- GridTable->ColumnCount = 4;
- }
- else if (comboBox1->SelectedItem == "5") {
- GridTable->ColumnCount = 5;
- }
- else if (comboBox1->SelectedItem == "6") {
- GridTable->ColumnCount = 6;
- }
- else if (comboBox1->SelectedItem == "7") {
- GridTable->ColumnCount = 7;
- }
- else if (comboBox1->SelectedItem == "8") {
- GridTable->ColumnCount = 8;
- }
- else if (comboBox1->SelectedItem == "9") {
- GridTable->ColumnCount = 9;
- }
- else if (comboBox1->SelectedItem == "10") {
- GridTable->ColumnCount = 10;
- }
- GridTable->ColumnHeadersVisible = true;
- for (int i = 0; i < GridTable->ColumnCount; i++)
- {
- GridTable->Columns[i]->HeaderCell->Value = Convert::ToString(i + 1);
- }
- }
- private: System::Void ButtonReady_Click(System::Object^ sender, System::EventArgs^ e) {
- using namespace std;
- int n, i, a[100];
- n = GridTable->ColumnCount;
- for (i = 0; i < n; i++)
- a[i] = Convert::ToInt16(GridTable[i, 0]->Value);
- int max, nom;
- for (int i = 0; i < n - 1; i++)
- {
- max = a[i]; nom = i;
- for (int j = i + 1; j < n; j++)
- if (a[j] < max)
- {
- max = a[j];
- nom = j;
- }
- a[nom] = a[i];
- a[i] = max;
- }
- for (int i = 0; i < n; i++)
- GridTable[i, 0]->Value = Convert::ToString(a[i]);
- };
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment