Anonim_999

1

Dec 22nd, 2022 (edited)
825
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp27
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             float[] xValues = { -2.37f, -0.49f,7.51f};
  10.  
  11.             foreach (float value in xValues)
  12.                 Console.WriteLine($"x:{value} - y:{CalculationFunction(value)}");
  13.         }
  14.  
  15.         private static float CalculationFunction(float x)
  16.         {
  17.             float a = 2.1f;
  18.             float b = 6.7f;
  19.             float y;
  20.  
  21.             if (x < -2)
  22.                 y = MathF.Pow(x,3) + 2 * a;
  23.             else if (x < 5 && x >= -2)
  24.                 y = MathF.Log(MathF.Abs(MathF.Cos(b*x)),MathF.E);
  25.             else
  26.                 y = MathF.Pow(x,2) * MathF.Pow(MathF.E,x);
  27.             return y;
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment