Guest User

Untitled

a guest
Jan 21st, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace full5
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. //Equacio A*x2 +B*x+C=0
  13. int a, b, c;
  14. double x1 = 0;
  15. double x2 = 0;
  16.  
  17. Console.WriteLine("Posa un valor int per A:");
  18. a = Int32.Parse(Console.ReadLine());
  19. Console.WriteLine("Posa un valor int per B:");
  20. b = Int32.Parse(Console.ReadLine());
  21. Console.WriteLine("Posa un valor int per C:");
  22. c = Int32.Parse(Console.ReadLine());
  23.  
  24. equacio(ref a,ref b,ref c,ref x1,ref x2);
  25. Console.WriteLine("Resultat de la equacio amb X1={0,5:f2}", x1);
  26. //x2 = equacio(a, b, c);
  27. Console.WriteLine("Resultat de la equacio amb X2={0,5:f2}", x2);
  28. Console.WriteLine("");
  29. Console.WriteLine("");
  30. equacio2(ref x1, ref x2);
  31. Console.WriteLine("Resultat de la equacio amb X1={0,5:f2}", x1);
  32. //x2 = equacio(a, b, c);
  33. Console.WriteLine("Resultat de la equacio amb X2={0,5:f2}", x2);
  34.  
  35. Console.ReadLine();
  36. }
  37. static void equacio(ref int A,ref int B,ref int C,ref double x1,ref double x2)
  38. {
  39. //double x1= 0;
  40. // double x2 = 0;
  41.  
  42. x1 = (-B + Math.Sqrt(B * B - 4 * A * C)) / 2 * A;
  43. x2 = (-B - Math.Sqrt(B * B - 4 * A * C)) / 2 * A;
  44. }
  45.  
  46. static void equacio2(ref double x1, ref double x2)
  47. {
  48. int A = 1;
  49. int B = -5;
  50. int C = 6;
  51.  
  52. x1 = (-B + Math.Sqrt(B * B - 4 * A * C)) / 2 * A;
  53. x2 = (-B - Math.Sqrt(B * B - 4 * A * C)) / 2 * A;
  54. }
  55. }
  56. }
Add Comment
Please, Sign In to add comment