- •«Белгородский государственный национальный исследовательский университет»
- •Кафедра Прикладной информатики и информационных технологий
- •1 Курса группы 12002108
- •Белгород 2022 содержание
- •Введение
- •1 Общая постановка задачи
- •2 Разработка алгоритмов и структур данных
- •VidNum(poleVis, pole, dff)
- •VidNum()
- •3.1 Программирование задачи в консольном варианте
- •3.2 Программирование задачи с использованием экранных форм
- •4 Демонстрация разработанного программного приложения
- •4.1 Демонстрация задачи в консольном варианте
- •4.2 Демонстрация задачи с использованием экранных форм
- •Заключение
- •Список использованных источников
- •Приложение a
- •Приложение b
Приложение b
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
srand(time(NULL));
Int32 const razmP = 9;
Int32 lastRow = 0;
System::Int32^ S;
for (Int32 i = 0; i < 9; i++)
{
dataGridView1->Rows->Add();
if (checkBox1->Checked) dataGridView2->Rows->Add();
lastRow = dataGridView1->Rows->Count;
dataGridView1->Rows[lastRow - 1]->Cells[0]->Value = i + 1;
if (checkBox1->Checked) dataGridView2->Rows[lastRow - 1]->Cells[0]->Value = i + 1;
for (Int32 j = 0; j < razmP; j++)
{
dataGridView1->Rows[lastRow - 1]->Cells[j + 1]->Value = (Int32((i * 3 + i / 3 + j)) % (3 * 3) + 1);
if (checkBox1->Checked) dataGridView2->Rows[lastRow - 1]->Cells[j + 1]->Value = (Int32((i * 3 + i / 3 + j)) % (3 * 3) + 1);
}
}
lastRow = 0;
Int32 begS, endS;
for (Int32 povt = 0; povt < 1001; povt++) //Повторение перемешиваний
{
begS = (rand() % 3) * 3;
endS = begS + (rand() % 2 + 1);
for (Int32 i = 0; i < razmP; i++)
{
S = (System::Int32^)this->dataGridView1->Rows[i]->Cells[begS + 1]->Value;
dataGridView1->Rows[i]->Cells[begS + 1]->Value = dataGridView1->Rows[i]->Cells[endS + 1]->Value;
if (checkBox1->Checked)dataGridView2->Rows[i]->Cells[begS + 1]->Value = dataGridView2->Rows[i]->Cells[endS + 1]->Value;
dataGridView1->Rows[i]->Cells[endS + 1]->Value = S;
if (checkBox1->Checked)dataGridView2->Rows[i]->Cells[endS + 1]->Value = S;
}
for (Int32 i = 0; i < razmP; i++)
{
S = (System::Int32^)this->dataGridView1->Rows[begS]->Cells[i + 1]->Value;
dataGridView1->Rows[begS]->Cells[i + 1]->Value = dataGridView1->Rows[endS]->Cells[i + 1]->Value;
if (checkBox1->Checked)dataGridView2->Rows[begS]->Cells[i + 1]->Value = dataGridView2->Rows[endS]->Cells[i + 1]->Value;
dataGridView1->Rows[endS]->Cells[i + 1]->Value = S;
if (checkBox1->Checked)dataGridView2->Rows[endS]->Cells[i + 1]->Value = S;
}
}
Int32 kZero = 0;
Int32 ind = 0;
for (Int32 i = 0; i < razmP; i++)
{
for (Int32 j = 0; j < 4; j++)
{
ind = rand() % 9;
dataGridView1->Rows[i]->Cells[ind + 1]->Value = " ";
}
}
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)
{
dataGridView1->Rows->Clear();
dataGridView2->Rows->Clear();
}
