예제 #1
0
        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();
        }
예제 #2
0
        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";
        }