Форум программистов, компьютерный форум, киберфорум
C# для начинающих
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.50/6: Рейтинг темы: голосов - 6, средняя оценка - 4.50
1 / 1 / 0
Регистрация: 28.12.2013
Сообщений: 23
1

Составить программу по нахождению определителя квадратной матрицы 2 и 3 порядка

17.05.2014, 00:18. Показов 1188. Ответов 4
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Составить программу по нахождению определителя квадратной матрицы 2 и 3 порядка
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
17.05.2014, 00:18
Ответы с готовыми решениями:

Составить программу по нахождению определителя квадратной матрицы 2 и 3 порядка
Составить программу по нахождению определителя квадратной матрицы 2 и 3 порядка

Составить программу по нахождению определителя квадратной матрицы 2 и 3 порядка
Составить программу по нахождению определителя квадратной матрицы 2 и 3 порядка

Составить программу по нахождению определителя квадратной матрицы второго и третьего порядка по выбору
Составить программу по нахождению определителя квадратной матрицы второго и третьего порядка по...

Составить программу по нахождению определителя квадратной матрицы второго и третьего порядка по выбору
Составить программу по нахождению определителя квадратной матрицы второго и третьего порядка по...

4
191 / 180 / 114
Регистрация: 28.07.2013
Сообщений: 606
17.05.2014, 01:22 2
Вот кусок кода:
на форме кнопка button1, таблица для ввода данных матрицы (я взял dataGridView1), поле для вывода результата textBox1 и два переключателя RadioButton - rdBtn_2 для 2-го порадка и rdBtn_3 для 3-го
Кликните здесь для просмотра всего текста

C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
int a11,a12,a13,a21,a22,a23,a31,a32,a33;
void Button1Click(object sender, EventArgs e)
{
    if(rdBtn_2.Checked == true){
        a11 = Convert.ToInt32(dataGridView1.Rows[0].Cells[0].Value.ToString());
        a12 = Convert.ToInt32(dataGridView1.Rows[0].Cells[1].Value.ToString());
        a21 = Convert.ToInt32(dataGridView1.Rows[1].Cells[0].Value.ToString());
        a22 = Convert.ToInt32(dataGridView1.Rows[1].Cells[1].Value.ToString());
        textBox1.Text = Convert.ToString(a11*a22-a12*a21);
    }
    else if(rdBtn_3.Checked == true){
        a11 = Convert.ToInt32(dataGridView1.Rows[0].Cells[0].Value.ToString());
        a12 = Convert.ToInt32(dataGridView1.Rows[0].Cells[1].Value.ToString());
        a13 = Convert.ToInt32(dataGridView1.Rows[0].Cells[2].Value.ToString());
        a21 = Convert.ToInt32(dataGridView1.Rows[1].Cells[0].Value.ToString());
        a22 = Convert.ToInt32(dataGridView1.Rows[1].Cells[1].Value.ToString());
        a23 = Convert.ToInt32(dataGridView1.Rows[1].Cells[2].Value.ToString());
        a31 = Convert.ToInt32(dataGridView1.Rows[2].Cells[0].Value.ToString());
        a32 = Convert.ToInt32(dataGridView1.Rows[2].Cells[1].Value.ToString());
        a33 = Convert.ToInt32(dataGridView1.Rows[2].Cells[2].Value.ToString());
        textBox1.Text = Convert.ToString(a11*a22*a33-a11*a23*a32-a12*a21*a33+a12*a23*a31+a13*a21*a32-a13*a22*a31);
    }
}
void RdBtn_2CheckedChanged(object sender, EventArgs e)
{
    a11=0;a12=0;a13=0;a21=0;a22=0;a23=0;a31=0;a32=0;a33=0;
    dataGridView1.Rows.Clear();
    dataGridView1.Columns.Clear();
    for(int i=0;i<2;i++){
        dataGridView1.Columns.Add(i.ToString(),i.ToString());
        dataGridView1.Columns[i].Width = 30;
        dataGridView1.Rows.Add();
    }
}
void RdBtn_3CheckedChanged(object sender, EventArgs e)
{
    a11=0;a12=0;a13=0;a21=0;a22=0;a23=0;a31=0;a32=0;a33=0;
    dataGridView1.Rows.Clear();
    dataGridView1.Columns.Clear();
    for(int i=0;i<3;i++){
        dataGridView1.Columns.Add(i.ToString(),i.ToString());
        dataGridView1.Columns[i].Width = 30;
        dataGridView1.Rows.Add();
    }
}
0
309 / 309 / 215
Регистрация: 24.09.2013
Сообщений: 771
17.05.2014, 09:12 3
Составить программу по нахождению определителя квадратной матрицы 2 и 3 порядка
Что не так?
0
1 / 1 / 0
Регистрация: 28.12.2013
Сообщений: 23
19.05.2014, 14:16  [ТС] 4
не правильно считает Pikemaster

Добавлено через 7 минут
спс СвободныйНик но ето не то что мне надо

Добавлено через 2 минуты
а как вставлять код как СвободныйНик?
0
191 / 180 / 114
Регистрация: 28.07.2013
Сообщений: 606
19.05.2014, 19:43 5
В MainForm.cs:
Кликните здесь для просмотра всего текста

C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
public MainForm()
        {
            InitializeComponent();
        }
        
        int a11,a12,a13,a21,a22,a23,a31,a32,a33;
        
        void Button1Click(object sender, EventArgs e)
        {
            if(rdBtn_2.Checked == true){
                a11 = Convert.ToInt32(dataGridView1.Rows[0].Cells[0].Value.ToString());
                a12 = Convert.ToInt32(dataGridView1.Rows[0].Cells[1].Value.ToString());
                a21 = Convert.ToInt32(dataGridView1.Rows[1].Cells[0].Value.ToString());
                a22 = Convert.ToInt32(dataGridView1.Rows[1].Cells[1].Value.ToString());
                textBox1.Text = Convert.ToString(a11*a22-a12*a21);
            }
            else if(rdBtn_3.Checked == true){
                a11 = Convert.ToInt32(dataGridView1.Rows[0].Cells[0].Value.ToString());
                a12 = Convert.ToInt32(dataGridView1.Rows[0].Cells[1].Value.ToString());
                a13 = Convert.ToInt32(dataGridView1.Rows[0].Cells[2].Value.ToString());
                a21 = Convert.ToInt32(dataGridView1.Rows[1].Cells[0].Value.ToString());
                a22 = Convert.ToInt32(dataGridView1.Rows[1].Cells[1].Value.ToString());
                a23 = Convert.ToInt32(dataGridView1.Rows[1].Cells[2].Value.ToString());
                a31 = Convert.ToInt32(dataGridView1.Rows[2].Cells[0].Value.ToString());
                a32 = Convert.ToInt32(dataGridView1.Rows[2].Cells[1].Value.ToString());
                a33 = Convert.ToInt32(dataGridView1.Rows[2].Cells[2].Value.ToString());
                textBox1.Text = Convert.ToString(a11*a22*a33-a11*a23*a32-a12*a21*a33+a12*a23*a31+a13*a21*a32-a13*a22*a31);
            }
        }       
        void MainFormiLoad(object sender, EventArgs e)
        {
            a11=0;a12=0;a13=0;a21=0;a22=0;a23=0;a31=0;a32=0;a33=0;
            for(int i=0;i<2;i++){
                dataGridView1.Columns.Add(i.ToString(),i.ToString());
                dataGridView1.Columns[i].Width = 30;
                dataGridView1.Rows.Add();
                
            }
        }       
        void RdBtn_2CheckedChanged(object sender, EventArgs e)
        {
            a11=0;a12=0;a13=0;a21=0;a22=0;a23=0;a31=0;a32=0;a33=0;
            dataGridView1.Rows.Clear();
            dataGridView1.Columns.Clear();
            for(int i=0;i<2;i++){
                dataGridView1.Columns.Add(i.ToString(),i.ToString());
                dataGridView1.Columns[i].Width = 30;
                dataGridView1.Rows.Add();
                
            }
        }       
        void RdBtn_3CheckedChanged(object sender, EventArgs e)
        {
            a11=0;a12=0;a13=0;a21=0;a22=0;a23=0;a31=0;a32=0;a33=0;
            dataGridView1.Rows.Clear();
            dataGridView1.Columns.Clear();
            for(int i=0;i<3;i++){
                dataGridView1.Columns.Add(i.ToString(),i.ToString());
                dataGridView1.Columns[i].Width = 30;
                dataGridView1.Rows.Add();
                
            }
        }


и в дизайнере MainForm.Designer.cs:
Кликните здесь для просмотра всего текста

C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
private void InitializeComponent()
        {
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.button1 = new System.Windows.Forms.Button();
            this.dataGridView1 = new System.Windows.Forms.DataGridView();
            this.rdBtn_2 = new System.Windows.Forms.RadioButton();
            this.rdBtn_3 = new System.Windows.Forms.RadioButton();
            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
            this.SuspendLayout();
            // 
            // textBox1
            // 
            this.textBox1.Location = new System.Drawing.Point(26, 63);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(111, 20);
            this.textBox1.TabIndex = 0;
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(26, 25);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(75, 23);
            this.button1.TabIndex = 1;
            this.button1.Text = "button1";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.Button1Click);
            // 
            // dataGridView1
            // 
            this.dataGridView1.AllowUserToAddRows = false;
            this.dataGridView1.AllowUserToDeleteRows = false;
            this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
                                    | System.Windows.Forms.AnchorStyles.Left) 
                                    | System.Windows.Forms.AnchorStyles.Right)));
            this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.dataGridView1.Location = new System.Drawing.Point(26, 89);
            this.dataGridView1.Name = "dataGridView1";
            this.dataGridView1.Size = new System.Drawing.Size(218, 163);
            this.dataGridView1.TabIndex = 2;
            // 
            // rdBtn_2
            //
            this.rdBtn_2.Checked = true;
            this.rdBtn_2.Location = new System.Drawing.Point(158, 25);
            this.rdBtn_2.Name = "rdBtn_2";
            this.rdBtn_2.Size = new System.Drawing.Size(86, 24);
            this.rdBtn_2.TabIndex = 3;
            this.rdBtn_2.TabStop = true;
            this.rdBtn_2.Text = "2 порядка";
            this.rdBtn_2.UseVisualStyleBackColor = true;
            this.rdBtn_2.CheckedChanged += new System.EventHandler(this.RdBtn_2CheckedChanged);
            // 
            // rdBtn_3
            // 
            this.rdBtn_3.Location = new System.Drawing.Point(158, 55);
            this.rdBtn_3.Name = "rdBtn_3";
            this.rdBtn_3.Size = new System.Drawing.Size(86, 24);
            this.rdBtn_3.TabIndex = 4;
            this.rdBtn_3.Text = "3 порядка";
            this.rdBtn_3.UseVisualStyleBackColor = true;
            this.rdBtn_3.CheckedChanged += new System.EventHandler(this.RdBtn_3CheckedChanged);
            // 
            // MainForm
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(256, 264);
            this.Controls.Add(this.rdBtn_3);
            this.Controls.Add(this.rdBtn_2);
            this.Controls.Add(this.dataGridView1);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.textBox1);
            this.Name = "MainForm";
            this.Text = "MainForm";         
            this.Load += new System.EventHandler(this.MainFormLoad);
            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();
        }
        private System.Windows.Forms.RadioButton rdBtn_3;
        private System.Windows.Forms.RadioButton rdBtn_2;
        private System.Windows.Forms.DataGridView dataGridView1;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.TextBox textBox1;


Цитата Сообщение от lagigod Посмотреть сообщение
не правильно считает Pikemaster
а у меня его код правильно считает (только там для матрицы случайные числа - замени на свои и всё )
0
19.05.2014, 19:43
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
19.05.2014, 19:43
Помогаю со студенческими работами здесь

Немного доработать метод по нахождению определителя квадратной матрицы
Добрый день, есть класс, помогите пожалуйста дописать метод по нахождению определителя квадратной...

Нахождение определителя квадратной матрицы второго порядка
Составить программу по нахождению определителя квадратной матрицы второго порядку.

Windows Worms приложение по нахождению определителя матрицы nxn
Прошу помощи в написании Windows Worms приложение по нахождению определителя матрицы nxn. Заранее...

Составьте программу, для получения квадратной матрицы порядка n следующего вида
Cоставьте программу, для получения квадратной матрицы порядка n следующего вида


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
5
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru