Vla_DOS

Lab1

Apr 26th, 2022
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Lab1
  4. {
  5.     class Program
  6.     {
  7.         static double f(double x)
  8.         {
  9.             double s = 0;
  10.             if (x > 3)
  11.             {
  12.                 double p = Math.Sin(x);
  13.                 double sq = p * p;
  14.                 for (int i = 1; i <= 17; i += 2)
  15.                 {
  16.                     s += p;
  17.                     p *= sq;
  18.                 }
  19.                 return s;
  20.             }
  21.             s = 15;
  22.             double t = x;
  23.             for (int i = 0; i < 5; i++)
  24.             {
  25.                 t = Math.Tan(t);
  26.                 s += t;
  27.             }
  28.             return s;
  29.         }
  30.  
  31.         static void Main(string[] args)
  32.         {
  33.             Console.Write("a = ");
  34.             double a = double.Parse(Console.ReadLine());
  35.             Console.Write("b = ");
  36.             double b = double.Parse(Console.ReadLine());
  37.             double fa = f(a);
  38.             double fb = f(b);
  39.             double u = fa > fb ? fa : fb;
  40.             //Console.WriteLine("f(a) = " + fa);
  41.             //Console.WriteLine("f(b) = " + fb);
  42.             Console.WriteLine("u = " + u);
  43.         }
  44.     }
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment