using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double a, b, c, delta, x1, x2;
Console.WriteLine("Podaj współczynniki równania kwadratowego:");
Console.Write("a="); a = double.Parse( Console.ReadLine() );
Console.Write("b="); b = double.Parse( Console.ReadLine() );
Console.Write("c="); c = double.Parse( Console.ReadLine() );
delta = (b*b) - (4*a*c);
if (delta >= 0)
{
x1 = (- b - Math.Sqrt(delta)) / (2 * a);
x2 = (- b + Math.Sqrt(delta)) / (2 * a);
Console.WriteLine("x1="+x1);
Console.WriteLine("x2=" + x2);
}
else
{
x1 = - b / (2 * a);
x2 = Math.Sqrt(-delta) / (2 * a);
Console.WriteLine("x1=" + x1 + "+j" + x2);
Console.WriteLine("x2=" + x1 + "-j" + x2);
}
Console.ReadKey();
}
}
}
x2 = Math.Sqrt(-delta) / (2 * a)
x2 = Math.Sqrt(math.abs(delta)) / (2 * a)
math.pow podstawa wykładnik
double b;
Boolean ok;
b = Double.Parse(textBox2.text);
ok = Double.TryParse(textBox2.text, out b);
double a;
Boolean ok;
a = Double.Parse(textBox1.text);
ok = Double.TryParse(textBox1.text, out a);
double c;
Boolean ok;
c = Double.Parse(textBox3.text);
ok = Double.TryParse(textBox3.text, out c);
_________________________________________________________________________
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 WindowsFormsApplication39
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
double a, b, c, delta, x1, x2;
a = (Double.Parse(textBox1.Text));
b = (Double.Parse(textBox2.Text));
c = (Double.Parse(textBox3.Text));
delta = Math.Pow(b, 2) - 4 * a * c;
textBox6.Text = delta.ToString();
if (delta > 0)
{
x1 = (-b - Math.Sqrt(delta)) / (2 * a);
x2 = (-b + Math.Sqrt(delta)) / (2 * a);
textBox4.Text = x1.ToString();
textBox5.Text = x2.ToString();
}
else
{
x1 = -b / (2 * a);
x2 = Math.Sqrt(-delta) / (2 * a);
textBox4.Text = x1.ToString() + "+j" + x1.ToString();
textBox5.Text = x2.ToString() + "-j" + x2.ToString();
}
}
}
}
__________________________________________________________________________
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 WindowsFormsApplication39
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
double a, b, c, delta, x1, x2;
a = (Double.Parse(textBox1.Text));
b = (Double.Parse(textBox2.Text));
c = (Double.Parse(textBox3.Text));
delta = Math.Pow(b, 2) - 4 * a * c;
textBox6.Text = delta.ToString();
if (delta >= 0)
{
x1 = (-b - Math.Sqrt(delta)) / (2 * a);
x2 = (-b + Math.Sqrt(delta)) / (2 * a);
textBox4.Text = x1.ToString();
textBox5.Text = x2.ToString();
}
else
{
x1 = -b / (2 * a);
x2 = Math.Sqrt(-delta) / (2 * a);
textBox4.Text = x1.ToString();
textBox5.Text = x2.ToString();
}
}
}
}
Wyszukiwarka
Podobne podstrony:
Równania kwadratowe matematykarozwiazywanie rownania kwadratowegorównanie kwadratowe konsolaNapisz program, ktory oblicza pierwiastki rownania kwadratowegoRownanie kwadratoweZestaw 1 Funkcja kwadratowa Funkcja homograficzna Równanie liniowebilans wodny metoda najmniejszych kwadratow rownanie bubendeyaZestaw4 funkcja kwadratowa wielomiany równaniaZadania ROWNANIA NIEROWNOSCI KWADRATOWERozgrzewka po kwadracie – cz 2uklady rownan (1)Tworzenie aplikacji okienkowych (programowanie)modele rownanwięcej podobnych podstron