-
Notifications
You must be signed in to change notification settings - Fork 0
/
using System;.cs
49 lines (37 loc) · 1.01 KB
/
using System;.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
class Program
{
static void Main()
{
int numA;
int numB;
double numH;
int iteration = 0;
Console.Write("Введите A: ");
numA = int.Parse(Console.ReadLine());
Console.Write("Введите B: ");
numB = int.Parse(Console.ReadLine());
Console.Write("Введите шаг (h): ");
numH = double.Parse(Console.ReadLine());
Console.WriteLine("{0,3} {1,5} {2,5}", "#", "x", "f(x)");
for (double x = numA; x <= numB; x += numH)
{
iteration++;
double y;
double xplus = x + 2;
if (xplus <= 1){
y= x *x;
}
else if (xplus <10){
y = 1 / (x + 2);
}
else
{
y = x + 2;
}
Console.WriteLine("{0,3} {1,5:f2} {2,5:f2} ", iteration, x, y);
}
Console.WriteLine("Нажмите Enter для завершения...");
Console.ReadLine();
}
}