Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. using System;
  2.  
  3. using System.Collections.Generic;
  4.  
  5. using System.Text;
  6.  
  7.  
  8.  
  9. namespace FunckjaKwa
  10.  
  11. {
  12.  
  13. class Math
  14.  
  15. {
  16.  
  17. public static void Kwadratowa(double a, double b, double c)
  18.  
  19. {
  20.  
  21. double delta = b * b - 4 * a * c;
  22.  
  23. double x, x1, x2;
  24.  
  25. if (delta > 0)
  26.  
  27. {
  28.  
  29. x1 = (-b + System.Math.Sqrt(delta)) / (2 * a);
  30.  
  31. x2 = (-b - System.Math.Sqrt(delta)) / (2 * a);
  32.  
  33. Console.WriteLine("Twoje x1 wynosi: " + x1);
  34.  
  35. Console.WriteLine("Twoje x2 wynosi: " + x2);
  36.  
  37. }
  38.  
  39. else if (delta < 0)
  40.  
  41. {
  42.  
  43. Console.WriteLine("Twoja delta wynosi: " + delta + ". Brak rozwiązania");
  44.  
  45. }
  46.  
  47. else
  48.  
  49. {
  50.  
  51. x = (-b + System.Math.Sqrt(delta)) / (2 * a);
  52.  
  53. Console.WriteLine("Twoje x wynosi: " +x);
  54.  
  55. }
  56.  
  57. }
  58.  
  59.  
  60.  
  61.  
  62.  
  63. static void Main(string[] args)
  64.  
  65. {
  66.  
  67. double a, b, c;
  68.  
  69. Console.WriteLine("Podaj liczby a, b i c funkcji kwadratowej");
  70.  
  71. a = double.Parse(Console.ReadLine());
  72.  
  73. b = double.Parse(Console.ReadLine());
  74.  
  75. c = double.Parse(Console.ReadLine());
  76.  
  77.  
  78. Kwadratowa(a, b, c);
  79.  
  80. Console.ReadLine();
  81. }
  82.  
  83. }
  84.  
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement