Anonim_999

2.3

Dec 22nd, 2022
818
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp27
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Console.Write("Длина отрезка: [a,b]. Укажите a: ");
  10.             string aInput = Console.ReadLine();
  11.             Console.Write("Укажите b: ");
  12.             string bInput = Console.ReadLine();
  13.             Console.WriteLine("Укажите шаг dx (пример: 0,3): ");
  14.             string dxInput = Console.ReadLine();
  15.             double a, b, dx;
  16.  
  17.             if (double.TryParse(aInput,out a)
  18.                 && double.TryParse(bInput, out b)
  19.                 && double.TryParse(dxInput,out dx))
  20.             {
  21.                 if (a < b && dx > 0)
  22.                     Tabl(a,b,dx);
  23.                 else
  24.                     Console.WriteLine("a - не должно быть блольше b и шаг дожен быть больше нуля");
  25.             }
  26.             else
  27.             {
  28.                 Console.WriteLine("Ошибка ввода!");
  29.             }
  30.         }
  31.  
  32.         private static void Tabl(double a, double b, double dx)
  33.         {
  34.             for (double x = a; x <= b; x += dx)
  35.                 Console.WriteLine($"x: {x} - y:{Func(x)}");
  36.         }
  37.  
  38.         private static double Func(double x)
  39.         {
  40.             return Math.Pow(Math.Sin(Math.Pow(Math.PI, x)),2);
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment