Exemple #1
0
        public Form1()
        {
            InitializeComponent();

            dataGridView1.RowCount    = 1;
            dataGridView1.ColumnCount = 2;
            button1.Visible           = true;
            Iteration.Count_x         = 1;
            string s;

            for (int i = 0; i < Iteration.Count_x; i++)
            {
                s = String.Format("x{0}", i);

                dataGridView1.Columns[i].HeaderText = s;
            }
            dataGridView1.Columns[Iteration.Count_x].HeaderText = "b";
            int a = 1;

            for (int i = 0; i < 100; i++)
            {
                a = Test_matrix.NextSimp(a);
                domainUpDown1.Items.Insert(0, a);
            }
            domainUpDown1.SelectedIndex = domainUpDown1.Items.Count - 1;
            button1.Visible             = true;
            dataGridView2.Visible       = true;
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                int a = int.Parse(domainUpDown1.Text) - 1;
                a = Test_matrix.NextSimp(a);
                domainUpDown1.Text = a.ToString();
                Iteration.Galua    = a;
                if (Val())
                {
                    Iteration.coefficients = new int[Iteration.Count_x, Iteration.Count_x + 1];
                    for (int i = 0; i < Iteration.Count_x + 1; i++)
                    {
                        for (int j = 0; j < Iteration.Count_x; j++)
                        {
                            Iteration.coefficients[j, i] = int.Parse(dataGridView1[i, j].Value.ToString());
                        }
                    }
                    int det;
                    det = Test_matrix.CountSolution(Iteration.Count_x, Iteration.coefficients);
                    det = det % Iteration.Galua;
                    if (det == 0 || !Test_matrix.All(Iteration.coefficients))
                    {
                        MessageBox.Show("Система неопределена!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        Iteration.Massx();

                        dataGridView2.Visible     = true;
                        dataGridView2.ColumnCount = (int)Iteration.Count_x;
                        dataGridView2.RowCount    = 1;
                        for (int i = 0; i < Iteration.Count_x; i++)
                        {
                            dataGridView2[i, 0].Value = Iteration.MassX[i];
                        }
                        string s;
                        for (int i = 0; i < Iteration.Count_x; i++)
                        {
                            s = String.Format("x{0}", i + 1);
                            dataGridView2.Columns[i].HeaderText = s;
                        }
                    }
                }
            }catch (Exception)
            {
                MessageBox.Show("Система не совместна!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            //
        }