Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp27
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Длина отрезка: [a,b]. Укажите a: ");
- string aInput = Console.ReadLine();
- Console.Write("Укажите b: ");
- string bInput = Console.ReadLine();
- Console.WriteLine("Укажите шаг dx (пример: 0,3): ");
- string dxInput = Console.ReadLine();
- double a, b, dx;
- if (double.TryParse(aInput,out a)
- && double.TryParse(bInput, out b)
- && double.TryParse(dxInput,out dx))
- {
- if (a < b && dx > 0)
- Tabl(a,b,dx);
- else
- Console.WriteLine("a - не должно быть блольше b и шаг дожен быть больше нуля");
- }
- else
- {
- Console.WriteLine("Ошибка ввода!");
- }
- }
- private static void Tabl(double a, double b, double dx)
- {
- for (double x = a; x <= b; x += dx)
- Console.WriteLine($"x: {x} - y:{Func(x)}");
- }
- private static double Func(double x)
- {
- return Math.Pow(Math.Sin(Math.Pow(Math.PI, x)),2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment