Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Nauka_1
  8. {
  9. public class Program
  10. {
  11. public static void Main()
  12. {
  13. int A = 2, B = 3, C = -2;
  14.  
  15. if (A == 0)
  16. {
  17. Console.WriteLine("Funkcja nie jest kwadratowa");
  18. }
  19. else
  20. {
  21. double delta = B * B - 4 * A * C;
  22.  
  23. if (delta < 0)
  24. {
  25. Console.WriteLine("Delta jest mniejsza od 0, brak rozwiązań");
  26. }
  27. else
  28. {
  29. double wynik;
  30. if (delta == 0)
  31. {
  32. wynik = -B / (2 * A);
  33. }
  34. else
  35. {
  36. wynik = (-B - Math.Sqrt(delta)) / (2 * A);
  37. Console.WriteLine("x1 = " + wynik);
  38. wynik = (-B + Math.Sqrt(delta)) / (2 * A);
  39. Console.WriteLine("x2 = " + wynik);
  40. Console.ReadKey();
  41. }
  42. }
  43. }
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement