Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Z_2
- {
- class Program
- {
- static void Main(string[] args)
- {
- int q = 1;
- while (q == 1)
- {
- Console.Write("введите начало диапазона. a= ");
- double a = double.Parse(Console.ReadLine());
- Console.Write("введите конец диапазона. b= ");
- double b = double.Parse(Console.ReadLine());
- Console.Write("введите размер шага. h= ");
- double h = double.Parse(Console.ReadLine());
- double z;
- for (double i = a; i <= b; i = i + h)
- {
- Console.WriteLine("При x ={0}, y ={1}", i, f(i));
- if (i != b)
- {
- i+=h;
- Console.WriteLine("При x ={0}, y ={1}", i, f(i,out z));
- }
- }
- Console.Write("если хотите продолжить введите 1 : ");
- q = int.Parse(Console.ReadLine());
- }
- }
- static double f(double x)
- {
- if (x < 0)
- {
- return -4;
- }
- else
- {
- if (x < 1)
- {
- double y = Math.Pow(x, 2) + 3 * x + 4;
- return y;
- }
- else
- {
- return 2;
- }
- }
- }
- static void f(double x, out double y)
- {
- if (x < 0)
- {
- y = -4;
- }
- else
- {
- if (x < 1)
- {
- y = Math.Pow(x, 2) + 3 * x + 4;
- }
- else
- {
- y = 2;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement