Advertisement
Czempina

Untitled

Oct 15th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace TestConsole.Mathematic
  5. {
  6.     public class QuadricFunctionCalculator
  7.     {
  8.         public List<double> GetResults(double a, double b, double c)
  9.         {
  10.             double delta = Math.Pow(b,2) - (4 * a * c);
  11.  
  12.             if (delta > 0)
  13.             {
  14.                 double p1 = (-b - System.Math.Sqrt(delta)) / (2 * a);
  15.                 double p2 = (-b + System.Math.Sqrt(delta)) / (2 * a);
  16.                 return new List<double> { p1, p2 };
  17.             }
  18.             else if (delta == 0)
  19.             {
  20.                 double p0 = (-b) / (2 * a);
  21.                 return new List<double> { p0 };
  22.             }
  23.             return new List<double> { };
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement