Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace WindowsFormsApplication5
- {
- public partial class Form1 : Form
- {
- Form2 f2 = new Form2();
- public Form1()
- {
- InitializeComponent();
- }
- public double a, b, c, d, x1, x2, p, q, x, i;
- internal void button1_Click(object sender, EventArgs e)
- {
- try
- {
- a = double.Parse(textBox1.Text);
- if (a == 0)
- {
- textBox4.Text = "A musi byc rozne od 0";
- }
- else
- {
- b = double.Parse(textBox2.Text);
- c = double.Parse(textBox3.Text);
- d = Math.Pow(b, 2) - 4 * a * c;
- p = -b / 2 * a;
- q = -d / 4 * a;
- if (d >= 0)
- {
- x1 = -b - Math.Sqrt(d) / (2 * a);
- x2 = -b + Math.Sqrt(d) / (2 * a);
- textBox4.Text = "Delta =" + d.ToString()+ Environment.NewLine;
- textBox4.Text += "x1=" + x1.ToString() + " x2=" + x2.ToString() + Environment.NewLine;
- textBox4.Text += "p=" + p.ToString() + " q=" + q.ToString() + Environment.NewLine;
- textBox4.Text += "Postac ogolna f(x)=" + a.ToString() + "x^2+" + b.ToString() + "x+" + c.ToString() + Environment.NewLine;
- textBox4.Text += "Postac iloczynowa: f(x)=" + a.ToString() + "(x-(" + x1.ToString() + "))(x-(" + x2.ToString() + "))" + Environment.NewLine;
- textBox4.Text += "Postac kanoniczna: f(x)=" + a.ToString() + "(x-(" + p.ToString() + "))^2+" + q.ToString() + Environment.NewLine;
- }
- else
- {
- if (f2.getOption1())
- {
- x = -b / 2 * a;
- i = Math.Sqrt(Math.Abs(d)) / (2 * a);
- textBox4.Text = "Delta =" + d.ToString() + Environment.NewLine;
- textBox4.Text += "x1=" + x.ToString() + "+j" + i.ToString() + Environment.NewLine;
- textBox4.Text += "x2=" + x.ToString() + "-j" + i.ToString() + Environment.NewLine;
- textBox4.Text += "Postac ogolna f(x)=" + a.ToString() + "x^2+" + b.ToString() + "x+" + c.ToString() + Environment.NewLine;
- textBox4.Text += "Postac iloczynowa: f(x)=" + a.ToString() + "(x-(" + x.ToString() + ")+j" + i.ToString() + ")(x-(" + x.ToString() + ")-j" + i.ToString() + ")" + Environment.NewLine;
- textBox4.Text += "Postac kanoniczna: f(x)=" + a.ToString() + "(x-(" + p.ToString() + "))^2+" + q.ToString() + Environment.NewLine;
- }
- else
- {
- textBox4.Text = "Delta =" + d.ToString() + Environment.NewLine;
- textBox4.Text +="Delta jest ujemna, brak rozwiazan";
- }
- }
- }
- }
- catch
- {
- textBox4.Text = "Wprowadz poprawne dane";
- }
- }
- internal void button2_Click(object sender, EventArgs e)
- {
- f2.ShowDialog();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void label2_Click(object sender, EventArgs e)
- {
- }
- private void label3_Click(object sender, EventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement