private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Panel^ panel1;
private: System::Windows::Forms::DataGridView^ dataGridView2;
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Button^ button4;
private: System::Windows::Forms::Panel^ panel2;
private: System::Windows::Forms::DataGridView^ dataGridView1;
private: System::Windows::Forms::Button^ button5;
private: System::Windows::Forms::Button^ button6;
private:
/// <summary>
/// Требуется переменная конструктора.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Обязательный метод для поддержки конструктора - не изменяйте
/// содержимое данного метода при помощи редактора кода.
/// </summary>
void InitializeComponent(void)
{
this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
this->panel1 = (gcnew System::Windows::Forms::Panel());
this->dataGridView2 = (gcnew System::Windows::Forms::DataGridView());
this->button3 = (gcnew System::Windows::Forms::Button());
this->button4 = (gcnew System::Windows::Forms::Button());
this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
this->panel2 = (gcnew System::Windows::Forms::Panel());
this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView());
this->button5 = (gcnew System::Windows::Forms::Button());
this->button6 = (gcnew System::Windows::Forms::Button());
this->groupBox3 = (gcnew System::Windows::Forms::GroupBox());
this->comboBox3 = (gcnew System::Windows::Forms::ComboBox());
this->comboBox2 = (gcnew System::Windows::Forms::ComboBox());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label1 = (gcnew System::Windows::Forms::Label());
this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
this->panel3 = (gcnew System::Windows::Forms::Panel());
this->button2 = (gcnew System::Windows::Forms::Button());
this->button1 = (gcnew System::Windows::Forms::Button());
this->statusStrip1 = (gcnew System::Windows::Forms::StatusStrip());
this->toolStripStatusLabel1 = (gcnew System::Windows::Forms::ToolStripStatusLabel());
this->colorDialog1 = (gcnew System::Windows::Forms::ColorDialog());
this->groupBox1->SuspendLayout();
this->panel1->SuspendLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView2))->BeginInit();
this->groupBox2->SuspendLayout();
this->panel2->SuspendLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView1))->BeginInit();
this->groupBox3->SuspendLayout();
this->panel3->SuspendLayout();
this->statusStrip1->SuspendLayout();
this->SuspendLayout();
//
// groupBox1
//
this->groupBox1->Controls->Add(this->panel1);
this->groupBox1->Location = System::Drawing::Point(12, 12);
this->groupBox1->Name = L"groupBox1";
this->groupBox1->Size = System::Drawing::Size(372, 261);
this->groupBox1->TabIndex = 2;
this->groupBox1->TabStop = false;
this->groupBox1->Text = L"Матрица смежности";
//
// panel1
//
this->panel1->Controls->Add(this->dataGridView2);
this->panel1->Controls->Add(this->button3);
this->panel1->Controls->Add(this->button4);
this->panel1->Location = System::Drawing::Point(6, 19);
this->panel1->Name = L"panel1";
this->panel1->Size = System::Drawing::Size(360, 236);
this->panel1->TabIndex = 9;
//
// dataGridView2
//
this->dataGridView2->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
this->dataGridView2->Location = System::Drawing::Point(3, 5);
this->dataGridView2->Name = L"dataGridView2";
this->dataGridView2->Size = System::Drawing::Size(354, 227);
this->dataGridView2->TabIndex = 8;
//
// button3
//
this->button3->Location = System::Drawing::Point(263, 358);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(159, 23);
this->button3->TabIndex = 7;
this->button3->Text = L"Выбор цвета окна";
this->button3->UseVisualStyleBackColor = true;
//
// button4
//
this->button4->Location = System::Drawing::Point(12, 358);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(245, 23);
this->button4->TabIndex = 5;
this->button4->Text = L"Сгенерировать и вычислить";
this->button4->UseVisualStyleBackColor = true;
//
// groupBox2
//
this->groupBox2->Controls->Add(this->panel2);
this->groupBox2->Location = System::Drawing::Point(399, 12);
this->groupBox2->Name = L"groupBox2";
this->groupBox2->Size = System::Drawing::Size(374, 261);
this->groupBox2->TabIndex = 3;
this->groupBox2->TabStop = false;
this->groupBox2->Text = L"Результат";
//
// panel2
//
this->panel2->Controls->Add(this->dataGridView1);
this->panel2->Controls->Add(this->button5);
this->panel2->Controls->Add(this->button6);
this->panel2->Location = System::Drawing::Point(6, 15);
this->panel2->Name = L"panel2";
this->panel2->Size = System::Drawing::Size(360, 240);
this->panel2->TabIndex = 10;
//
// dataGridView1
//
this->dataGridView1->Location = System::Drawing::Point(5, 6);
this->dataGridView1->Name = L"dataGridView1";
this->dataGridView1->Size = System::Drawing::Size(362, 227);
this->dataGridView1->TabIndex = 8;
this->dataGridView1->CellContentClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &Form1::DataGridView1_CellContentClick);
//
// button5
//
this->button5->Location = System::Drawing::Point(263, 358);
this->button5->Name = L"button5";
this->button5->Size = System::Drawing::Size(159, 23);
this->button5->TabIndex = 7;
this->button5->Text = L"Выбор цвета окна";
this->button5->UseVisualStyleBackColor = true;
//
// button6
//
this->button6->Location = System::Drawing::Point(12, 358);
this->button6->Name = L"button6";
this->button6->Size = System::Drawing::Size(245, 23);
this->button6->TabIndex = 5;
this->button6->Text = L"Сгенерировать и вычислить";
this->button6->UseVisualStyleBackColor = true;
//
// groupBox3
//
this->groupBox3->Controls->Add(this->comboBox3);
this->groupBox3->Controls->Add(this->comboBox2);
this->groupBox3->Controls->Add(this->label3);
this->groupBox3->Controls->Add(this->label2);
this->groupBox3->Controls->Add(this->label1);
this->groupBox3->Controls->Add(this->comboBox1);
this->groupBox3->Location = System::Drawing::Point(12, 279);
this->groupBox3->Name = L"groupBox3";
this->groupBox3->Size = System::Drawing::Size(720, 75);
this->groupBox3->TabIndex = 4;
this->groupBox3->TabStop = false;
this->groupBox3->Text = L"Настройки";
//
// comboBox3
//
this->comboBox3->FormattingEnabled = true;
this->comboBox3->Location = System::Drawing::Point(473, 36);
this->comboBox3->Name = L"comboBox3";
this->comboBox3->Size = System::Drawing::Size(180, 21);
this->comboBox3->TabIndex = 11;
//
// comboBox2
//
this->comboBox2->FormattingEnabled = true;
this->comboBox2->Location = System::Drawing::Point(230, 36);
this->comboBox2->Name = L"comboBox2";
this->comboBox2->Size = System::Drawing::Size(180, 21);
this->comboBox2->TabIndex = 10;
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(456, 20);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(246, 13);
this->label3->TabIndex = 9;
this->label3->Text = L"Максимальное значение случайного элемента";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(210, 20);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(240, 13);
this->label2->TabIndex = 8;
this->label2->Text = L"Минимальное значение случайного элемента";
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(9, 20);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(183, 13);
this->label1->TabIndex = 7;
this->label1->Text = L"Размерность матрицы смежности";
//
// comboBox1
//
this->comboBox1->FormattingEnabled = true;
this->comboBox1->Location = System::Drawing::Point(12, 36);
this->comboBox1->Name = L"comboBox1";
this->comboBox1->Size = System::Drawing::Size(180, 21);
this->comboBox1->TabIndex = 5;
//
// panel3
//
this->panel3->Controls->Add(this->button2);
this->panel3->Controls->Add(this->button1);
this->panel3->Location = System::Drawing::Point(0, 2);
this->panel3->Name = L"panel3";
this->panel3->Size = System::Drawing::Size(784, 390);
this->panel3->TabIndex = 8;
//
// button2
//
this->button2->Location = System::Drawing::Point(263, 358);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(159, 23);
this->button2->TabIndex = 7;
this->button2->Text = L"Выбор цвета окна";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click_1);
//
// button1
//
this->button1->Location = System::Drawing::Point(12, 358);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(245, 23);
this->button1->TabIndex = 5;
this->button1->Text = L"Сгенерировать и вычислить";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// statusStrip1
//
this->statusStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) { this->toolStripStatusLabel1 });
this->statusStrip1->Location = System::Drawing::Point(0, 395);
this->statusStrip1->Name = L"statusStrip1";
this->statusStrip1->Size = System::Drawing::Size(785, 22);
this->statusStrip1->TabIndex = 6;
this->statusStrip1->Text = L"statusStrip1";
this->statusStrip1->ItemClicked += gcnew System::Windows::Forms::ToolStripItemClickedEventHandler(this, &Form1::statusStrip1_ItemClicked);
//
// toolStripStatusLabel1
//
this->toolStripStatusLabel1->Name = L"toolStripStatusLabel1";
this->toolStripStatusLabel1->Size = System::Drawing::Size(118, 17);
this->toolStripStatusLabel1->Text = L"toolStripStatusLabel1";
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(785, 417);
this->Controls->Add(this->statusStrip1);
this->Controls->Add(this->groupBox3);
this->Controls->Add(this->groupBox2);
this->Controls->Add(this->groupBox1);
this->Controls->Add(this->panel3);
this->Name = L"Form1";
this->Text = L"Floyd Warshall";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->groupBox1->ResumeLayout(false);
this->panel1->ResumeLayout(false);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView2))->EndInit();
this->groupBox2->ResumeLayout(false);
this->panel2->ResumeLayout(false);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView1))->EndInit();
this->groupBox3->ResumeLayout(false);
this->groupBox3->PerformLayout();
this->panel3->ResumeLayout(false);
this->statusStrip1->ResumeLayout(false);
this->statusStrip1->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
comboBox1->Items->Add("3");
comboBox1->Items->Add("4");
comboBox1->Items->Add("5");
comboBox1->Items->Add("6");
comboBox1->Items->Add("7");
comboBox1->Items->Add("8");
comboBox1->Items->Add("9");
comboBox1->Items->Add("10");
comboBox1->SelectedItem = 1;
comboBox1->Text = "4";
comboBox2->Items->Add("1");
comboBox2->Items->Add("2");
comboBox2->Items->Add("3");
comboBox2->Items->Add("4");
comboBox2->Items->Add("5");
comboBox2->Items->Add("6");
comboBox2->Items->Add("7");
comboBox2->Items->Add("8");
comboBox2->SelectedItem = 1;
comboBox2->Text = "2";
comboBox3->Items->Add("10");
comboBox3->Items->Add("12");
comboBox3->Items->Add("13");
comboBox3->Items->Add("14");
comboBox3->Items->Add("15");
comboBox3->Items->Add("16");
comboBox3->Items->Add("17");
comboBox3->Items->Add("18");
comboBox3->SelectedItem = 1;
comboBox3->Text = "12";
toolStripStatusLabel1->Text= "Можно приступать к вычислениям. Выберите размерность матрицы смежности.";
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
int n, i, j, k,a,b;
n = int::Parse(comboBox1->SelectedItem->ToString());
a = int::Parse(comboBox2->SelectedItem->ToString());
b = int::Parse(comboBox3->SelectedItem->ToString());
dataGridView1->ColumnCount = n;
dataGridView1->RowCount = n;
dataGridView1->SetBounds(10, 10, 50 * n + n, 50 * n + n);
dataGridView2->ColumnCount = n;
dataGridView2->RowCount = n;
dataGridView2->SetBounds(10, 10, 50 * n + n, 50 * n + n);
FloydWarshallClass object;
object.generate_source(n,a,b);
object.generate_result(n);
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
dataGridView2->Columns[i]->Width = 30;
dataGridView2->Rows[i]->Cells[j]->Value = object.g1[i][j];
}
}
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
dataGridView1->Columns[i]->Width = 30;
dataGridView1->Rows[i]->Cells[j]->Value = object.g2[i][j];
}
}
}
private: System::Void statusStrip1_ItemClicked(System::Object^ sender, System::Windows::Forms::ToolStripItemClickedEventArgs^ e) {
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
colorDialog1->ShowDialog();
panel3->BackColor = colorDialog1->Color;
}
private: System::Void button2_Click_1(System::Object^ sender, System::EventArgs^ e) {
colorDialog1->ShowDialog();
panel3->BackColor = colorDialog1->Color;
}
private: System::Void DataGridView1_CellContentClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
}
};
}
8. Тестирование
Для тестирования необходимо изменять настройки в компонентах ComboBox. Для решения задачи необходимо нажимать кнопку «Сгенерировать и вычислить».
1. Анисимов, А.Е. Сборник заданий по основаниям программирования: учеб. пособие / А.Е. Анисимов, В.В. Пупышев. М.: Интернет-ун-т информ. технологий; БИНОМ. Лаборатория знаний, 2006. 348с. <15>
2. Макконелл, Д. Основы современных алгоритмов: учеб. Пособие. М.: Техносфера, 2006. 368 с. <7>
3. Подбельский, В.В. Язык Си+:Учеб. пособие для вузов / В.В. Подбельский. 5-е изд. М.: Финансы и статистика, 2003. 560с. <13>
4. Павловская, Т.А. C/C++:Программирование на языке высокого уровня: Учебник для вузов / Т.А. Павловская. М. и др.: Питер, 2004. 461с.<7>
5. Ганеев, Р.М. Проектирование интерфейса пользователя средствами Win32 API: учеб. пособие для вузов / Р. М. Ганеев. 2-е изд., испр. и доп. М.: Горячая линия-Телеком, 2007. 358 с.<3>
1. Вирт Н. Алгоритмы + структуры данных = программы. М.; Mиp, 1985. 281 с.
2. Шлее, М. Профессиональное программирование на С++ / М. Шлее. СПб.: БХВ-Петербург, 2005. 544с.: ил. + 1 CD. (В подлиннике). <3>
3. Страуструп, Б. Язык программирования Си++:Спец.изд. / Б.Страуструп;Пер.сангл.С.Анисимова,М.Кононова;Подред.Ф.Андреева,А.Ушаков. М.: Бином, 2004. 1098с. <4>