Advertisement
filin

laba_2_z_3_mk1

Sep 16th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.59 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Z_3
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int q = 1;
  14.             while (q == 1)
  15.             {
  16.                 Console.Write("введите начало диапазона. a= ");
  17.                 double a = double.Parse(Console.ReadLine());
  18.                 Console.Write("введите конец диапазона. b= ");
  19.                 double b = double.Parse(Console.ReadLine());
  20.                 Console.Write("введите размер шага. h= ");
  21.                 double h = double.Parse(Console.ReadLine());
  22.                 for (double i = a; i <= b; i = i + h)
  23.                 {
  24.                     myfunction(i);
  25.                    
  26.                 }
  27.  
  28.                 Console.Write("если хотите продолжить введите 1 :  ");
  29.                 q = int.Parse(Console.ReadLine());
  30.             }
  31.  
  32.         }
  33.         public static void myfunction(double x)
  34.         {
  35.             if (x < 0)
  36.             {
  37.                 Console.WriteLine("При x={0}, y=-4", x);
  38.             }
  39.             else
  40.             {
  41.                 if (x < 1)
  42.                 {
  43.                     double y = Math.Pow(x, 2) + 3 * x + 4;
  44.                     Console.WriteLine("При x={0}, y={1}", x, y);
  45.  
  46.                 }
  47.                 else
  48.                 {
  49.                     Console.WriteLine("При x={0}, y=2", x);
  50.                 }
  51.             }
  52.  
  53.         }
  54.  
  55.  
  56.  
  57.  
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement