Level2.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //#define IsTestDownLevel2
  2. #define IsDriverUpperSec
  3. #define IsDriverUpperTan
  4. #define IsDriverUpperCtg
  5. #define IsDriverUpperLog
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace FunctionSystem
  12. {
  13. public static class Level2
  14. {
  15. #if IsTestDownLevel2
  16. #region заглушки
  17. public static double Sec(double x) => 1;
  18. public static double Tan(double x) => 1;
  19. public static double Ctg(double x) => 1;
  20. public static double Log(double x, double osn) => 1;
  21. #endregion
  22. #else
  23. #if IsDriverUpperSec
  24. public static double Sec(double x)
  25. {
  26. Console.WriteLine($"Cos - {Level1.Cos(x)}");
  27. return 0;
  28. }
  29. #else
  30. public static double Sec(double x)
  31. {
  32. return 1 / Level1.Cos(x);
  33. }
  34. #endif
  35. #if IsDriverUpperTan
  36. public static double Tan(double x)
  37. {
  38. Console.WriteLine($"Sin - {Level0.Sin(x)}");
  39. Console.WriteLine($"Cos - {Level1.Cos(x)}");
  40. return 0;
  41. }
  42. #else
  43. public static double Tan(double x)
  44. {
  45. return Level0.Sin(x) / Level1.Cos(x);
  46. }
  47. #endif
  48. #if IsDriverUpperCtg
  49. public static double Ctg(double x)
  50. {
  51. Console.WriteLine($"Cos - {Level1.Cos(x)}");
  52. Console.WriteLine($"Sin - {Level0.Sin(x)}");
  53. return 0;
  54. }
  55. #else
  56. public static double Ctg(double x)
  57. {
  58. return Level1.Cos(x) / Level0.Sin(x);
  59. }
  60. #endif
  61. #if IsDriverUpperLog
  62. public static double Log(double x, double osn)
  63. {
  64. Console.WriteLine($"Ln(x) - {Level0.Ln(x)}");
  65. Console.WriteLine($"Ln({osn}) - {Level0.Ln(osn)}");
  66. return 0;
  67. }
  68. #else
  69. public static double Log(double x, double osn)
  70. {
  71. return Level0.Ln(x) / Level0.Ln(osn);
  72. }
  73. #endif
  74. #endif
  75. }
  76. }