Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- double Delta(double a, double b, double c)
- {
- return b * b - 4 * a * c;
- }
- public void Pierwiastki(double a, double b, double c, out double x1, out double x2)
- {
- if (Delta(a, b, c) == 0)
- {
- x1 = (-b) / (2 * a);
- x2 = 0;
- }
- else
- {
- x1 = ((-b) - (Math.Sqrt(Delta(a, b, c)))) / (2 * a);
- x2= ((-b) + (Math.Sqrt(Delta(a, b, c)))) / (2 * a);
- }
- }
- private void btn1_Click(object sender, RoutedEventArgs e)
- {
- double a = Convert.ToDouble(txtA.Text);
- double b = Convert.ToDouble(txtB.Text);
- double c = Convert.ToDouble(txtC.Text);
- double x1, x2;
- Pierwiastki(a, b, c,out x1,out x2);
- lblWynik.Content = x1.ToString("F2");
- lblWynik.Content = x2.ToString("F2");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement