private void Return_Search_Click(object sender, EventArgs e) { stopwatch.Start(); if (!int.TryParse(textBox1.Text, out int x) || x <= 0) { MessageBox.Show("Wrong Inpput", "Message"); return; } N = Convert.ToInt32(textBox1.Text); InitializeDataGridView(Convert.ToInt32(textBox1.Text)); QueensProblem cb = new QueensProblem(); cb.Init(N); label1.Text = cb.Solve().ToString(); foreach (int[] i in cb.GetResults()) { AddToList(i, N); } stopwatch.Stop(); label5.Text = stopwatch.ElapsedMilliseconds.ToString() + "msec"; TextWriter writer = new StreamWriter(@"C:\Users\vladi\OneDrive\Рабочий стол\Cursovaya\answers.txt"); foreach (var item in listBox1.Items) { writer.WriteLine(item.ToString()); } writer.Close(); }
private void ReturnSearchSolvingToolStripMenuItem_Click(object sender, EventArgs e) { stopwatch.Start(); if (!int.TryParse(textBox1.Text, out int x) || x <= 0) { MessageBox.Show("Wrong Inpput", "Message"); return; } N = Convert.ToInt32(textBox1.Text); InitializeDataGridView(Convert.ToInt32(textBox1.Text)); QueensProblem cb = new QueensProblem(); cb.Init(N); label1.Text = cb.Solve().ToString(); foreach (int[] i in cb.GetResults()) { AddToList(i, N); } stopwatch.Stop(); label5.Text = stopwatch.ElapsedMilliseconds.ToString() + "msec"; }