daily pastebin goal
75%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  public partial class MainWindow : Window
  2.     {
  3.         public MainWindow()
  4.         {
  5.             InitializeComponent();
  6.         }
  7.         double Delta(double a, double b, double c)
  8.         {
  9.             return b * b - 4 * a * c;
  10.         }
  11.        public void Pierwiastki(double a, double b, double c, out double x1, out double x2)
  12.         {
  13.             if (Delta(a, b, c) == 0)
  14.             {
  15.                 x1 = (-b) / (2 * a);
  16.                 x2 = 0;
  17.             }
  18.             else
  19.             {
  20.                 x1 = ((-b) - (Math.Sqrt(Delta(a, b, c)))) / (2 * a);
  21.                 x2= ((-b) + (Math.Sqrt(Delta(a, b, c)))) / (2 * a);
  22.             }
  23.                
  24.            
  25.  
  26.         }
  27.            private void btn1_Click(object sender, RoutedEventArgs e)
  28.         {
  29.             double a = Convert.ToDouble(txtA.Text);
  30.             double b = Convert.ToDouble(txtB.Text);
  31.             double c = Convert.ToDouble(txtC.Text);
  32.             double x1, x2;
  33.             Pierwiastki(a, b, c,out x1,out x2);
  34.             lblWynik.Content = x1.ToString("F2");
  35.             lblWynik.Content = x2.ToString("F2");
  36.  
  37.         }
  38.  
  39.        
  40.     }
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top