private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Bạn chưa nhập số y"); } else { x = doc.chuyen(textBox1.Text); if (Math.Abs(Math.Round(x, 3)) <= 1) { if (Math.Round(x, 3) == 1) { ngh1 = "x = π/2 + k2π"; } else if (Math.Round(x, 3) == -1) { ngh2 = "x = -π/2 + k2π"; } else if (Math.Round(x, 3) == 0) { ngh2 = "x = kπ"; } else { double y = Math.Asin(x) * 180 / Math.PI; int y1 = new int(); if (int.TryParse(Math.Round(y, 3).ToString(), out y1)) { if (giai.timthay(y1)) { ngh1 = "x = " + giai.gdb[y1 + 200] + " + k2π"; ngh2 = "x = " + giai.gdb[180 - y1 + 200] + " + k2π"; } else { ngh1 = "x = " + "arcsin(" + Math.Round(x, 3) + ") + k2π"; ngh2 = "x = " + "π - arcsin(" + Math.Round(x, 3) + ") + k2π"; } } else { ngh1 = "x = " + "arcsin(" + Math.Round(x, 3) + ") + k2π"; ngh2 = "x = " + "π - arcsin(" + Math.Round(x, 3) + ") + k2π"; } } } else { ngh1 = " Vô nghiệm"; } label3.Text = ngh1; label4.Text = ngh2; } }
private void button1_Click(object sender, EventArgs e) { label12.Text = ""; label13.Text = ""; if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "") { MessageBox.Show("Bạn chưa nhập đủ ba số a,b,c!"); } else if (textBox4.Text == "" || textBox5.Text == "") { MessageBox.Show("Bạn chưa nhập đủ 2 số m,n!"); } else { a = doc.chuyen(textBox1.Text); b = doc.chuyen(textBox2.Text); c = doc.chuyen(textBox3.Text); m = doc.chuyen(textBox4.Text); n = doc.chuyen(textBox5.Text); sbeta = ""; st1 = ""; st2 = ""; st = ""; string som = "", son = ""; string maum = ""; if (n > 0) { son = " - " + Math.Round(n, 3).ToString(); } if (n < 0) { son = " + " + Math.Round(-n, 3).ToString(); } if (m != 1) { som = "/" + Math.Round(m, 3).ToString(); } if (a * a + b * b >= Math.Round(c * c, 3)) { double kt1 = Math.Round(Math.Acos(a / Math.Sqrt(a * a + b * b)), 5); double kt2 = Math.Round(Math.Asin(b / Math.Sqrt(a * a + b * b)), 5); if (kt1 == kt2) { beta = kt1; } if (-kt1 == kt2) { beta = -kt1; } if (kt1 == Math.PI - kt2) { beta = kt1; } if (-kt1 == Math.PI - kt2) { beta = kt1; } canab = Math.Sqrt(a * a + b * b); if (Math.Round(c / canab, 5) == 1 || Math.Round(c / canab, 5) == -1 || Math.Round(c, 5) == 0) { if (Math.Round(c / canab, 5) == 1) { t = Math.PI / 2 - beta; } else if (Math.Round(c / canab, 5) == -1) { t = -Math.PI / 2 - beta; } else if (Math.Round(c, 5) == 0) { t = -beta; } timst(t + beta); string sot = ""; if (Math.Round(t, 3) != 0) { sot = Math.Round(t, 3).ToString(); } double y = t * 180 / Math.PI; int y1 = 0; if (int.TryParse(Math.Round(y, 3).ToString(), out y1)) { if (giai.timthay(y1)) { double mau = m * giai.mau[y1 + 200]; if (mau != 1) { maum = "/" + Math.Round(mau, 3).ToString(); } ngh1 = "x = " + giai.tu[y1 + 200] + maum + son + som + "+ k2π" + som; } else { ngh1 = "x = " + sot + som + son + som + "+ k2π" + som; } } else { ngh1 = "x = " + sot + som + son + som + "+ k2π" + som; } } else { t1 = Math.Asin(c / canab) - beta; t2 = Math.PI - Math.Asin(c / canab) - beta; timst1(t1 + beta); timst2(t2 + beta); string sot1 = ""; if (Math.Round(t1, 3) != 0) { sot1 = Math.Round(t1, 3) + ""; } string sot2 = ""; if (Math.Round(t2, 3) != 0) { sot2 = Math.Round(t2, 3) + ""; } double y = t1 * 180 / Math.PI; int y1 = 0; if (int.TryParse(Math.Round(y, 3).ToString(), out y1)) { if (giai.timthay(y1)) { double mau = m * giai.mau[y1 + 200]; if (mau != 1) { maum = "/" + Math.Round(mau, 3).ToString(); } ngh1 = "x = " + giai.tu[y1 + 200] + maum + son + som + "+ k2π" + som; } else { ngh1 = "x = " + sot1 + som + son + som + "+ k2π" + som; } } else { ngh1 = "x = " + sot1 + som + son + som + "+ k2π" + som; } y = t2 * 180 / Math.PI; y1 = 0; if (int.TryParse(Math.Round(y, 3).ToString(), out y1)) { if (giai.timthay(y1)) { double mau = m * giai.mau[y1 + 200]; if (mau != 1) { maum = "/" + Math.Round(mau, 3).ToString(); } ngh2 = "x = " + giai.tu[y1 + 200] + maum + son + som + "+ k2π" + som; } else { ngh2 = "x = " + sot2 + som + son + som + "+ k2π" + som; } } else { ngh2 = "x = " + sot2 + som + son + som + "+ k2π" + som; } } kq[1] = ngh1; kq[2] = ngh2; for (int i = 1; i < 3; i++) { for (int j = i + 1; j < 3; j++) { if (kq[i] == "" && kq[j] != "") { kq[i] = kq[j]; kq[j] = ""; } } } label11.Text = "Phương trình có nghiệm:"; label12.Text = kq[1]; label13.Text = kq[2]; label14.Text = "(với k là số nguyên)"; } else { label11.Text = "Phương trình vô nghiệm"; } Button button2 = new Button(); button2.Font = button1.Font; button2.Text = "Lời giải chi tiết"; button2.AutoSize = true; this.Controls.Add(button2); button2.Location = new Point(502, 140); button2.Click += Button2_Click; this.AcceptButton = button2; button4.Text = "Đồ thị"; button4.Font = button1.Font; button4.Location = new Point(502, 180); button4.Size = new Size(128, 36); this.Controls.Add(button4); button4.Click += Button4_Click; } }
private void button1_Click(object sender, EventArgs e) { for (int i = 1; i < 30; i++) { lg[i] = new Label(); pt[i] = new PictureBox(); } for (int i = 1; i < 30; i++) { lg[i].Size = new Size(0, 0); pt[i].Size = new Size(0, 0); } for (int i = 1; i < 9; i++) { ngh[i] = ""; } label8.Text = ""; label9.Text = ""; label10.Text = ""; label11.Text = ""; label12.Text = ""; label13.Text = ""; label14.Text = ""; label15.Text = ""; soa = ""; sob = ""; soc = ""; so2k = ""; soc_2k = ""; if ((!radioButton1.Checked && !radioButton2.Checked) || (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "")) { if (!radioButton1.Checked && !radioButton2.Checked) { MessageBox.Show("Bạn chưa chọn dạng của f(x)!"); } else if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "") { MessageBox.Show("Bạn chưa nhập đủ 4 số a,b,c,k!"); } } else { a = doc.chuyen(textBox1.Text); b = doc.chuyen(textBox2.Text); c = doc.chuyen(textBox3.Text); k = doc.chuyen(textBox4.Text); if (radioButton1.Checked) { ham = "sin(x)"; } else { ham = "cos(x)"; } if (a > 0) { if (Math.Round(a, 3) != 1) { soa = Math.Round(a, 3) + ""; } } if (a < 0) { if (Math.Round(a, 3) != -1) { soa = "-" + Math.Round(-a, 3); } } if (b > 0) { if (Math.Round(b, 3) != 1) { sob = " + " + Math.Round(b, 3) + "t "; } else { sob = " + t "; } } if (b < 0) { if (Math.Round(b, 3) != -1) { sob = "- " + Math.Round(-b, 3) + "t "; } else { sob = " - t "; } } if (c > 0) { soc = "+ " + Math.Round(c, 3); } if (c < 0) { soc = "- " + Math.Round(-c, 3); } if (-2 * k > 0) { so2k = "+ " + Math.Round((-2 * k), 3); } if (-2 * k < 0) { so2k = "- " + Math.Round(-(-2 * k), 3); } if (c - 2 * k > 0) { soc_2k = "+ " + Math.Round((c - 2 * a * k), 3); } if (c - 2 * k < 0) { soc_2k = "- " + Math.Round(-(c - 2 * a * k), 3); } if (k > 0) { sok = "+ " + Math.Round(k, 3); } if (k < 0) { sok = "- " + Math.Round(-k, 3); } giai.radioButton1.Checked = true; giai.textBox2.Text = textBox1.Text; giai.textBox3.Text = textBox2.Text; giai.textBox4.Text = (c - 2 * a * k).ToString(); giai.button1_Click(button1, e); d = giai.d; if (giai.d == 0) { t1 = giai.x; } if (giai.d > 0) { t1 = giai.x1; t2 = giai.x2; } if (d >= 0) { if (radioButton1.Checked) { giai.radioButton1.Checked = true; } else { giai.radioButton2.Checked = true; } giai.textBox2.Text = "1"; giai.textBox3.Text = (-t1).ToString(); giai.textBox4.Text = textBox4.Text; giai.button1_Click(button1, e); d1 = giai.d; if (giai.d == 0) { x1 = giai.x; ngh[1] = giai.ngh1; ngh[2] = giai.ngh2; } if (giai.d > 0) { x1 = giai.x1; x2 = giai.x2; ngh[1] = giai.ngh1; ngh[2] = giai.ngh2; ngh[3] = giai.ngh3; ngh[4] = giai.ngh4; } } if (d > 0) { if (radioButton1.Checked) { giai.radioButton1.Checked = true; } else { giai.radioButton2.Checked = true; } giai.radioButton1.Checked = true; giai.textBox2.Text = "1"; giai.textBox3.Text = (-t2).ToString(); giai.textBox4.Text = textBox4.Text; giai.button1_Click(button1, e); d2 = giai.d; if (giai.d == 0) { x3 = giai.x; ngh[5] = giai.ngh1; ngh[6] = giai.ngh2; } if (giai.d > 0) { x3 = giai.x1; x4 = giai.x2; ngh[5] = giai.ngh1; ngh[6] = giai.ngh2; ngh[7] = giai.ngh3; ngh[8] = giai.ngh4; } } for (int i = 1; i < 9; i++) { kq[i] = ngh[i]; } for (int i = 1; i < 9; i++) { for (int j = i + 1; j < 9; j++) { if (kq[i] == "" && kq[j] != "") { kq[i] = ngh[j]; kq[j] = ""; } } } if (ngh[1] == "" && ngh[2] == "" && ngh[3] == "" && ngh[4] == "" && ngh[5] == "" && ngh[6] == "" && ngh[7] == "" && ngh[8] == "") { label7.Text = "Phương trình vô nghiệm"; } else { label7.Text = "Phương trình có nghiệm"; label8.Text = kq[1]; label9.Text = kq[2]; label10.Text = kq[3]; label11.Text = kq[4]; label12.Text = kq[5]; label13.Text = kq[6]; label14.Text = kq[7]; label15.Text = kq[8]; label19.Text = "(với k là số nguyên)"; } Button button2 = new Button(); button2.Text = "Lời giải chi tiết"; button2.Font = button1.Font; button2.Location = new Point(380, 350); button2.AutoSize = true; this.Controls.Add(button2); button2.Click += Button2_Click; button4.Text = "Đồ thị"; button4.Font = button1.Font; button4.Location = new Point(380, 390); button4.Size = new Size(128, 36); this.Controls.Add(button4); button4.Click += Button4_Click; } }
private void button1_Click(object sender, EventArgs e) { ngh1 = ""; ngh2 = ""; ngh3 = ""; label8.Text = ""; label9.Text = ""; label10.Text = ""; label7.Text = ""; soa = ""; sob = ""; soc = ""; sod = ""; if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "") { MessageBox.Show("Bạn chưa nhập đủ bốn số a,b,c,d!"); } else { Docdulieu doc = new Docdulieu(); a = doc.chuyen(textBox1.Text); b = doc.chuyen(textBox2.Text); c = doc.chuyen(textBox3.Text); d = doc.chuyen(textBox4.Text); if (a == d) { ngh1 = "x = π/2 + kπ"; kt = true; } giai.radioButton3.Checked = true; giai.textBox2.Text = (a - d).ToString(); giai.textBox3.Text = b.ToString(); giai.textBox4.Text = (c - d).ToString(); giai.button1_Click(button1, e); ngh2 = giai.ngh1; ngh3 = giai.ngh3; kq[1] = ngh1; kq[2] = ngh2; kq[3] = ngh3; for (int i = 1; i < 5; i++) { for (int j = i + 1; j < 5; j++) { if (kq[i] == "" && kq[j] != "") { kq[i] = kq[j]; kq[j] = ""; } } } if (ngh1 == "" && ngh2 == "" && ngh3 == "") { label7.Text = "Phương trình vô nghiệm"; } else { label7.Text = "Phương trình có nghiệm:"; label8.Text = kq[1]; label9.Text = kq[2]; label10.Text = kq[3]; label11.Text = "(với k là số nguyên)"; } Button button2 = new Button(); button2.Text = "Lời giải chi tiết"; button2.Font = button1.Font; button2.Location = new Point(300, 265); button2.AutoSize = true; this.Controls.Add(button2); button2.Click += Button2_Click; this.AcceptButton = button2; button4.Text = "Đồ thị"; button4.Font = button1.Font; button4.Location = new Point(300, 305); button4.Size = new Size(128, 36); this.Controls.Add(button4); button4.Click += Button4_Click; } }
private void button1_Click(object sender, EventArgs e) { label8.Text = ""; label9.Text = ""; label10.Text = ""; label11.Text = ""; soa = ""; sob = ""; soc = ""; sod = ""; soe = ""; sof = ""; if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "") { MessageBox.Show("Bạn chưa nhập đủ 4 số a,b,c,d"); } else { a = doc.chuyen(textBox1.Text); b = doc.chuyen(textBox2.Text); c = doc.chuyen(textBox3.Text); d = doc.chuyen(textBox4.Text); g = doc.chuyen(textBox5.Text); f = doc.chuyen(textBox6.Text); if (a + g >= 0) { if (Math.Round(a + g, 3) != 1) { soa = Math.Round(a + g, 3) + ""; } } if (a + g < 0) { if (Math.Round(a + g, 3) != -1) { soa = "-" + Math.Round(-a - g, 3); } } if (b + f >= 0) { if (Math.Round(b + f, 3) != 1) { sob = " + " + Math.Round(b + f, 3); } else { sob = "+ "; } } if (b + f < 0) { if (Math.Round(b + f, 3) != -1) { sob = "- " + Math.Round(-b - f, 3); } else { sob = "- "; } } if (c + g > 0) { if (Math.Round(c + g, 3) != 1) { soc = "+ " + Math.Round(c + g, 3) + "tan(x) "; } } if (c + g < 0) { if (Math.Round(c + g, 3) != -1) { soc = "- " + Math.Round(-c - g, 3) + "tan(x) "; } } if (d + f > 0) { sod = "+ " + Math.Round(d + f, 3); } if (d + f < 0) { sod = "- " + Math.Round(-d - f, 3); } giai.radioButton3.Checked = true; giai.textBox2.Text = (a + g).ToString(); giai.textBox3.Text = (b + f).ToString(); giai.textBox4.Text = (g + c).ToString(); giai.textBox5.Text = (d + f).ToString(); giai.button1_Click(button1, e); ngh1 = giai.ngh1; ngh2 = giai.ngh3; ngh3 = giai.ngh5; if (a == 0) { ngh4 = "π/2 + k2π"; } kq[1] = ngh1; kq[2] = ngh2; kq[3] = ngh3; kq[4] = ngh4; for (int i = 1; i < 5; i++) { for (int j = i + 1; j < 5; j++) { if (kq[i] == "" && kq[j] != "") { kq[i] = kq[j]; kq[j] = ""; } } } if (ngh1 == "" && ngh2 == "" && ngh3 == "" & ngh4 == "") { label8.Text = "Phương trình vô nghiệm"; } else { label8.Text = "Phương trình có nghiệm:"; label9.Text = kq[1]; label10.Text = kq[2]; label11.Text = kq[3]; label12.Text = kq[4]; label14.Text = "(với k là số nguyên)"; } Button button2 = new Button(); button2.Text = "Lời giải chi tiết"; button2.Font = button1.Font; button2.Location = new Point(370, 190); button2.AutoSize = true; this.Controls.Add(button2); button2.Click += Button2_Click; this.AcceptButton = button2; button4.Text = "Đồ thị"; button4.Font = button1.Font; button4.Location = new Point(370, 230); button4.Size = new Size(128, 36); this.Controls.Add(button4); button4.Click += Button4_Click; } }
private void button1_Click(object sender, EventArgs e) { ngh1 = ""; ngh2 = ""; ngh3 = ""; ngh4 = ""; label10.Text = ""; label11.Text = ""; label12.Text = ""; label13.Text = ""; soa = ""; sob1 = ""; sob2 = ""; soc = ""; if ((radioButton1.Checked == false && radioButton2.Checked == false) || (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "")) { if (radioButton1.Checked == false && radioButton2.Checked == false) { MessageBox.Show("Bạn chưa chọn dạng phương trình!"); } else if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "") { MessageBox.Show("Bạn chưa nhập đủ ba số a,b,c"); } } else { a = doc.chuyen(textBox1.Text); b = doc.chuyen(textBox2.Text); c = doc.chuyen(textBox3.Text); if (radioButton1.Checked == true) { giai.textBox2.Text = b.ToString(); giai.textBox3.Text = (2 * a).ToString(); giai.textBox4.Text = (-2 * c - b).ToString(); giai.radioButton1.Checked = true; giai.button1_Click(button1, e); } else if (radioButton2.Checked) { giai.textBox2.Text = (-b).ToString(); giai.textBox3.Text = (-2 * a).ToString(); giai.textBox4.Text = (-2 * c + b).ToString(); giai.radioButton1.Checked = true; giai.button1_Click(button1, e); } if (giai.d < 0) { label9.Text = "Phương trình vô nghiệm"; } if (giai.d == 0) { if (Math.Abs(Math.Round(x, 3)) <= Math.Round(Math.Sqrt(2), 3)) { x = giai.x; if (Math.Round(x, 3) == 0) { ngh1 = "x = " + sin0(); } else if (Math.Round(x, 3) == Math.Round(Math.Sqrt(2), 3)) { ngh1 = "x = " + sin1(); } else if (Math.Round(x, 3) == -Math.Round(Math.Sqrt(2), 3)) { ngh1 = "x = " + sin_1(); } else { if (radioButton1.Checked == true) { if (Math.Round(x, 3) == 1) { ngh1 = "x = " + sinpi41(); ngh2 = "x = " + sinpi42(); } else { double y = Math.Asin(x / Math.Sqrt(2)) * 180 / Math.PI; int y1 = 0; if (int.TryParse(Math.Round(y, 5).ToString(), out y1)) { if (giai.timthay(y1)) { double k = 180 / y1; ngh1 = "x = " + giai.gdb[y1 + 200 - 45] + " + k2π"; ngh2 = "x = " + giai.gdb[180 - y1 + 200 - 45] + " + k2π"; } else { ngh1 = "x = " + "arcsin(" + Math.Round(x, 3) + ") - π/4+ k2π"; ngh2 = "x = " + "π - arcsin(" + Math.Round(x, 3) + ") - π/4 + k2π"; } } else { ngh1 = "x = " + "arcsin(" + Math.Round(x, 3) + ") - π/4+ k2π"; ngh2 = "x = " + "π - arcsin(" + Math.Round(x, 3) + ") - π/4 + k2π"; } } } if (radioButton2.Checked == true) { if (Math.Round(x, 3) == -1) { ngh1 = "x = -π/2 + k2π"; ngh2 = "x = k2π"; } else { double y = Math.Asin(x / Math.Sqrt(2)) * 180 / Math.PI; int y1 = 0; if (int.TryParse(Math.Round(y, 5).ToString(), out y1)) { if (giai.timthay(y1)) { double k = 180 / y1; ngh1 = "x = " + giai.gdb[y1 + 200 - 45] + " + k2π"; ngh2 = "x = " + giai.gdb[180 - y1 + 200 - 45] + " + k2π"; } else { ngh1 = "x = " + "arccos(" + Math.Round(x, 3) + ") + π/4+ k2π"; ngh2 = "x = " + "π - arccos(" + Math.Round(x, 3) + ") + π/4 + k2π"; } } else { ngh1 = "x = " + "arccos(" + Math.Round(x, 3) + ") + π/4+ k2π"; ngh2 = "x = " + "π - arccos(" + Math.Round(x, 3) + ") + π/4 + k2π"; } } } } } } if (giai.d > 0) { x1 = giai.x1; x2 = giai.x2; if (Math.Abs(Math.Round(x1, 3)) <= Math.Round(Math.Sqrt(2), 3)) { x1 = giai.x1; if (Math.Round(x1, 3) == 0) { ngh1 = "x = " + sin0(); } else if (Math.Round(x1, 3) == Math.Round(Math.Sqrt(2), 3)) { ngh1 = "x = " + sin1(); } else if (Math.Round(x1, 3) == -Math.Round(Math.Sqrt(2), 3)) { ngh1 = "x = " + sin_1(); } else { if (radioButton1.Checked == true) { if (Math.Round(x1, 3) == 1) { ngh1 = "x = " + sinpi41(); ngh2 = "x = " + sinpi42(); } else { double y = Math.Asin(x1 / Math.Sqrt(2)) * 180 / Math.PI; int y1 = 0; if (int.TryParse(Math.Round(y, 5).ToString(), out y1)) { if (giai.timthay(y1)) { double k = 180 / y1; ngh1 = "x = " + giai.gdb[y1 + 200 - 45] + " + k2π"; ngh2 = "x = " + giai.gdb[180 - y1 + 200 - 45] + " + k2π"; } else { ngh1 = "x = " + "arcsin(" + Math.Round(x1, 3) + ") - π/4+ k2π"; ngh2 = "x = " + "π - arcsin(" + Math.Round(x1, 3) + ") - π/4 + k2π"; } } else { ngh1 = "x = " + "arcsin(" + Math.Round(x1, 3) + ") - π/4+ k2π"; ngh2 = "x = " + "π - arcsin(" + Math.Round(x1, 3) + ") - π/4 + k2π"; } } } if (radioButton2.Checked == true) { if (Math.Round(x1, 3) == -1) { ngh1 = "x = -π/2 + k2π"; ngh2 = "x = k2π"; } else { double y = Math.Asin(x1 / Math.Sqrt(2)) * 180 / Math.PI; int y1 = 0; if (int.TryParse(Math.Round(y, 5).ToString(), out y1)) { if (giai.timthay(y1)) { double k = 180 / y1; ngh1 = "x = " + giai.gdb[y1 + 200 - 45] + " + k2π"; ngh2 = "x = " + giai.gdb[180 - y1 + 200 - 45] + " + k2π"; } else { ngh1 = "x = " + "arccos(" + Math.Round(x1, 3) + ") + π/4+ k2π"; ngh2 = "x = " + "π - arccos(" + Math.Round(x1, 3) + ") + π/4 + k2π"; } } else { ngh1 = "x = " + "arccos(" + Math.Round(x1, 3) + ") + π/4+ k2π"; ngh2 = "x = " + "π - arccos(" + Math.Round(x1, 3) + ") + π/4 + k2π"; } } } } } if (Math.Abs(Math.Round(x2, 5)) <= Math.Round(Math.Sqrt(2), 3)) { x2 = giai.x2; if (Math.Round(x2, 3) == 0) { ngh1 = "x = " + sin0(); } else if (Math.Round(x2, 3) == Math.Round(Math.Sqrt(2), 3)) { ngh3 = "x = " + sin1(); } else if (Math.Round(x2, 3) == -Math.Round(Math.Sqrt(2), 3)) { ngh3 = "x = " + sin_1(); } else { if (radioButton1.Checked == true) { if (Math.Round(x2, 3) == 1) { ngh3 = "x = " + sinpi41(); ngh3 = "x = " + sinpi42(); } else { double y = Math.Asin(x2 / Math.Sqrt(2)) * 180 / Math.PI; int y1 = 0; if (int.TryParse(Math.Round(y, 5).ToString(), out y1)) { if (giai.timthay(y1)) { double k = 180 / y1; ngh3 = "x = " + giai.gdb[y1 + 200 - 45] + " + k2π"; ngh4 = "x = " + giai.gdb[180 - y1 + 200 - 45] + " + k2π"; } else { ngh3 = "x = " + "arcsin(" + Math.Round(x2, 3) + ") - π/4+ k2π"; ngh4 = "x = " + "π - arcsin(" + Math.Round(x2, 3) + ") - π/4 + k2π"; } } else { ngh3 = "x = " + "arcsin(" + Math.Round(x2, 3) + ") - π/4+ k2π"; ngh4 = "x = " + "π - arcsin(" + Math.Round(x2, 3) + ") - π/4 + k2π"; } } } if (radioButton2.Checked == true) { if (Math.Round(x2, 3) == -1) { ngh3 = "x = -π/2 + k2π"; ngh4 = "x = k2π"; } else { double y = Math.Asin(x2 / Math.Sqrt(2)) * 180 / Math.PI; int y1 = 0; if (int.TryParse(Math.Round(y, 5).ToString(), out y1)) { if (giai.timthay(y1)) { double k = 180 / y1; ngh3 = "x = " + giai.gdb[y1 + 200 - 45] + " + k2π"; ngh4 = "x = " + giai.gdb[180 - y1 + 200 - 45] + " + k2π"; } else { ngh3 = "x = " + "arccos(" + Math.Round(x2, 3) + ") + π/4+ k2π"; ngh4 = "x = " + "π - arccos(" + Math.Round(x2, 3) + ") + π/4 + k2π"; } } else { ngh3 = "x = " + "arccos(" + Math.Round(x2, 3) + ") + π/4+ k2π"; ngh4 = "x = " + "π - arc(" + Math.Round(x2, 3) + ") + π/4 + k2π"; } } } } } } kq[1] = ngh1; kq[2] = ngh2; kq[3] = ngh3; kq[4] = ngh4; for (int i = 1; i < 5; i++) { for (int j = i + 1; j < 5; j++) { if (kq[i] == "" && kq[j] != "") { kq[i] = kq[j]; kq[j] = ""; } } } if (ngh1 == "" && ngh2 == "" && ngh3 == "" && ngh4 == "") { label9.Text = "Phương trình vô nghiệm"; } else { label9.Text = "Phương trình có nghiệm:"; label10.Text = kq[1]; label11.Text = kq[2]; label12.Text = kq[3]; label13.Text = kq[4]; label5.Text = "(với k là số nguyên)"; } Button button2 = new Button(); button2.Text = "Lời giải chi tiết"; button2.Font = button1.Font; button2.Location = new Point(410, 160); button2.AutoSize = true; this.Controls.Add(button2); button2.Click += Button2_Click; this.AcceptButton = button2; button4.Text = "Đồ thị"; button4.Font = button1.Font; button4.Location = new Point(410, 200); button4.Size = new Size(128, 36); this.Controls.Add(button4); button4.Click += Button4_Click; } }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "") { MessageBox.Show("Bạn chưa nhập đủ 5 số a,b,c,m,n!"); } else { soa = ""; sob = ""; soc = ""; som = ""; somb = ""; son = ""; sonb = ""; sonc = ""; soamn = ""; somn = ""; socamn = ""; sot1 = ""; sot2 = ""; ngh1 = ""; ngh2 = ""; ngh3 = ""; ngh4 = ""; label9.Text = ""; label10.Text = ""; label11.Text = ""; label12.Text = ""; label13.Text = ""; a = doc.chuyen(textBox1.Text); b = doc.chuyen(textBox2.Text); c = doc.chuyen(textBox3.Text); m = doc.chuyen(textBox4.Text); n = doc.chuyen(textBox5.Text); if (a > 0) { if (Math.Round(a, 3) != 1) { soa = Math.Round(a, 3) + ""; } } if (a < 0) { if (Math.Round(a, 3) != -1) { soa = "-" + Math.Round(-a, 3); } } if (b > 0) { if (Math.Round(b, 3) != 1) { sob = " + " + Math.Round(b, 3) + "t "; } else { sob = "+ t "; } } if (b < 0) { if (Math.Round(b, 3) != -1) { sob = "- " + Math.Round(-b, 3) + "t "; } else { sob = "- t "; } } if (c > 0) { soc = "+ " + Math.Round(c, 3); } if (c < 0) { soc = "- " + Math.Round(-c, 3); } if (m > 0) { if (Math.Round(m, 3) != 1) { som = Math.Round(m, 3) + ""; } } if (m < 0) { if (Math.Round(m, 3) != -1) { som = "-" + Math.Round(-m, 3); } else { som = "-"; } } if (n > 0) { son = "+ " + Math.Round(n, 3); if (Math.Round(n, 3) != 1) { sonc = "+ " + Math.Round(n, 3); } else { sonc = "+ "; } } if (n < 0) { son = "- " + Math.Round(-n, 3); if (Math.Round(n, 3) != -1) { sonc = "- " + Math.Round(-n, 3); } else { sonc = "- "; } } if (Math.Round(m, 3) != 1 && Math.Round(m, 3) != -1) { somb = Math.Round(m * m, 3) + ""; } if (Math.Round(n, 3) != 1 && Math.Round(n, 3) != -1) { sonb = "+ " + Math.Round(n * n, 3) + ""; } else { sonb = "+ "; } if (2 * a * m * n > 0) { soamn = "- " + Math.Round(2 * a * m * n, 3); } if (2 * a * m * n < 0) { soamn = "+ " + Math.Round(-2 * a * m * n, 3); } if (2 * m * n > 0) { somn = "- " + Math.Round(2 * m * n, 3); } if (2 * m * n < 0) { somn = "+ " + Math.Round(-2 * m * n, 3); } if (c - 2 * a * m * n > 0) { socamn = "+ " + Math.Round(c - 2 * a * m * n, 3); } if (c - 2 * a * m * n < 0) { socamn = "- " + Math.Round(-c + 2 * a * m * n, 3); } giai.radioButton1.Checked = true; giai.textBox2.Text = a.ToString(); giai.textBox3.Text = b.ToString(); giai.textBox4.Text = (c - 2 * a * m * n).ToString(); giai.button1_Click(button1, e); d = giai.d; if (d == 0) { t1 = giai.x; } if (d > 0) { t1 = giai.x1; t2 = giai.x2; } if (t1 > 0) { if (Math.Round(t1, 3) != 1) { sot1 = "- " + Math.Round(t1, 3) + "tan(x)"; } else { sot1 = "- tan(x)"; } } if (t1 < 0) { if (Math.Round(t1, 3) != -1) { sot1 = "+ " + Math.Round(-t1, 3) + "tan(x)"; } else { sot1 = "+ tan(x)"; } } if (t2 > 0) { if (Math.Round(t2, 3) != 1) { sot2 = "- " + Math.Round(t2, 3) + "tan(x)"; } else { sot2 = "- tan(x)"; } } if (t2 < 0) { if (Math.Round(t2, 3) != -1) { sot2 = "+ " + Math.Round(-t2, 3) + "tan(x)"; } else { sot2 = "+ tan(x)"; } } if (d >= 0) { giai.radioButton3.Checked = true; giai.textBox2.Text = m.ToString(); giai.textBox3.Text = (-t1).ToString(); giai.textBox4.Text = n.ToString(); giai.button1_Click(button1, e); d1 = giai.d; if (d1 == 0) { x1 = giai.x; ngh1 = giai.ngh1; } if (d1 > 0) { x1 = giai.x1; x2 = giai.x2; ngh1 = giai.ngh1; ngh2 = giai.ngh3; } } if (d > 0) { giai.radioButton3.Checked = true; giai.textBox2.Text = m.ToString(); giai.textBox3.Text = (-t2).ToString(); giai.textBox4.Text = n.ToString(); giai.button1_Click(button1, e); d2 = giai.d; if (d2 == 0) { x3 = giai.x; ngh3 = giai.ngh1; } if (d2 > 0) { x3 = giai.x1; x4 = giai.x2; ngh3 = giai.ngh1; ngh4 = giai.ngh3; } } kq[1] = ngh1; kq[2] = ngh2; kq[3] = ngh3; kq[4] = ngh4; for ( int i = 1; i < 5; i++) { for (int j = i + 1; j < 5; j++) { if (kq[i] == "" && kq[j] != "") { kq[i] = kq[j]; kq[j] = ""; } } } if (ngh1 == "" && ngh2 == "" && ngh3 == "" && ngh4 == "") { label9.Text = "Phương trình vô nghiệm"; } else { label9.Text = "Phương trình có nghiệm:"; label10.Text = kq[1]; label11.Text = kq[2]; label12.Text = kq[3]; label13.Text = kq[4]; label17.Text = "(với k là số nguyên)"; } Button button2 = new Button(); button2.Text = "Lời giải chi tiết"; button2.Font = button1.Font; button2.Location = new Point(360, 220); button2.AutoSize = true; this.Controls.Add(button2); button2.Click += Button2_Click; this.AcceptButton = button2; button4.Text = "Đồ thị"; button4.Font = button1.Font; button4.Location = new Point(360, 260); button4.Size = new Size(128, 36); this.Controls.Add(button4); button4.Click += Button4_Click; } }