private static void Main string args double num double num2 double num

 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
private static void Main(string[] args)
{
double num;
double num2;
double num5;
double num6;
if (((args.Length > 1) && (args.Length <= 3)) || (args.Length == 0))
{
File.AppendAllText("test.txt", "Недостаточно аргументов");
Environment.Exit(0);
}
if (File.Exists("test.txt"))
{
File.Delete("test.txt");
}
if (!double.TryParse(args[0], out num))
{
File.AppendAllText("test.txt", "Первый аргумент не число");
Environment.Exit(0);
}
if (!double.TryParse(args[1], out num2))
{
File.AppendAllText("test.txt", "Второй аргумент не число");
Environment.Exit(0);
}
double num3 = double.Parse(args[2]);
double d = Math.Pow(num2, 2.0) - ((4.0 * num) * num3);
if ((d > 0.0) && (d < 10.0))
{
num5 = (-num2 + Math.Sqrt(d)) / (2.0 * num);
num6 = (-num2 - Math.Sqrt(d)) / (2.0 * num);
File.AppendAllText("test.txt", string.Concat(new object[] { "x1= ", num5, "\n x2= ", num6 }));
Environment.Exit(0);
}
if (d > 10.0)
{
num5 = (-num2 + Math.Sqrt(d)) / (2.0 * num);
num6 = (num2 - Math.Sqrt(d)) / (2.0 * num);
File.AppendAllText("test.txt", string.Concat(new object[] { "x1= ", num5, "\n x2= ", num6 }));
Environment.Exit(0);
}
if ((d < 0.0) && (d > -100.0))
{
File.AppendAllText("test.txt", "Действительных корней нет!");
Environment.Exit(0);
}
if (d < -100.0)
{
num5 = (-num2 + Math.Sqrt(d)) / (2.0 * num);
}
if ((d == 0.0) && (num != 0.0))
{
num5 = -num2 / (2.0 * num);
num6 = num2 / (2.0 * num);
File.AppendAllText("test.txt", string.Concat(new object[] { "x1= ", num5, "\n x2= ", num6 }));
Environment.Exit(0);
}
if ((d == 0.0) && (num == 0.0))
{
File.AppendAllText("test.txt", "Делить на 0 нельзя!");
Environment.Exit(0);
}
}