this->button1->TabIndex = 2;
this->button1->Text = L"确定";
this->button1->UseVisualStyleBackColor = false;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(265, 607);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(53, 12);
this->label1->TabIndex = 3;
this->label1->Text = L"输入N:";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(91, 606);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(41, 12);
this->label2->TabIndex = 3;
this->label2->Text = L"方案:";
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(592, 623);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->button1);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->comboBox1);
this->Name = L"Form1";
this->Text = L"Form1";
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
static int N=6,num=0;
static array
static array
static array
int Isable(int row)
{
for(int i=1;i
return 1;
}
void Queen(int row)
{
for(int cols=1;cols<=N;cols++)
{
site[row]=cols;
if(Isable(row))
{
if(row==N)
{
num++;
this->comboBox1->Items->Add("方案 "+num);
for(int i=1;i<=N;i++)
result[num,i]=site[i];
return;
}
Queen(row+1);
}
}
}
void Erase()
{
for(int i=1;i<=N;i++)
for(int j=1;j<=N;j++)
this->Controls->Remove(this->button[i,j]);
this->comboBox1->Items->Clear();
N=Convert::ToInt16(this->textBox1->Text);
num=0;
for(int i=1;i<=N;i++)
site[i]=0;
}
void Show()
{
int a;
a=600/N;
for(int i=1;i<=N;i++)
for(int j=1;j<=N;j++)
{
this->button[i,j] = (gcnew System::Windows::Forms::Button());
this->button[i,j]->Loc