using System using System Collections Generic using System Linq using

 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
66
67
68
69
70
71
72
73
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using Microsoft.Office.Interop.Excel;
//using Microsoft.Office.Core;
namespace ConsoleApplication1
{
class Program
{
static void print(List<string> X, List<string> Y, List<string> F)
{
double XMax = 0;
double YMax = 0;
double FMax = 0;
for (int i = 0; i < X.Count; i++)
{
if (X[i].Length > XMax)
XMax = X[i].Length;
if (Y[i].Length > YMax)
YMax = Y[i].Length;
if (F[i].Length > FMax)
FMax = F[i].Length;
}
for (int i = 0; i < X.Count; i++)
{
while (X[i].Length < XMax)
X[i] = X[i] + " ";
while (Y[i].Length < YMax)
Y[i] = Y[i] + " ";
while (F[i].Length < FMax)
F[i] = F[i] + " ";
}
for (int i = 0; i < X.Count; i++)
{
Console.Write(F[i] + " ");
Console.Write(X[i] + " ");
Console.Write(Y[i] + " ");
Console.WriteLine();
}
}
static void Main(string[] args)
{
int a = 0;
double b = 5;
double x = a;
double h = 0.5;
double y = -40 / Math.Pow(3 * Math.PI, 2);
int i = 0;
double f = 0;
var X = new List<string>();
var Y = new List<string>();
var F = new List<string>();
X.Add("x");
Y.Add("y");
F.Add("f");
do
{
x = a + h * i;
y = y + f * h;
f = -4.68 * Math.Pow(0.3 * Math.PI, 2) * y;
i++;
X.Add(x.ToString());
Y.Add(y.ToString());
F.Add(f.ToString());
} while (x + 0.00001 < b);
print(X, Y, F);
Console.ReadKey();
}
}
}