Я не могу принять результат моей функции. Работает, если 1 и 2, но для третьей дозы она не работает. он просто печатает от 2 до 9, в результате он должен решить уравнение в функции и дать мне результат, но он не работает. Скажите, пожалуйста, что не так с этим?Я не могу принять результат своей функции
class Program
{
public double tri(double a,double b,double c,double d,int n)
{
double[] w = new double[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int m = n - 2;
double result = 0;
for (int i = 1; i <= m; i++)
{
b = (b - c) * (a/b);
d = (d - d) * (a/b);
w[i] = d/b;
}
for (int j = m ; j <= 1; j--)
{
w[j] = (d - w[j + 1] * c)/b;
result = w[j];
}
return result;
}
static void Main(string[] args)
{
int n = 10;
double dif_co = 0.00000036;
double t_int = 0.1;
double s = 0.117;
double n_dis = 1.111;
double[] temp = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
double a, b, c, d;
Program heat = new Program();
for (int i = 1; i <= n; i++)
{
if (i == 1)
{
a = 0;
b = 1;
c = 0;
d = 700;
temp[0]=700;
Console.WriteLine("temprature is {0}", temp[0].ToString());
}
else if (i == n)
{
a = 0;
b = 1;
c = 0;
d= 300;
temp[9]=300;
Console.WriteLine("temprature is {0}", temp[9].ToString());
}
else
{
a = -((2 * dif_co * t_int) - s * n_dis * t_int);
b = (4 * (t_int * t_int)) + 4 * dif_co * t_int;
c = (2 * dif_co * t_int) + (s * n_dis * t_int);
d = ((2 * dif_co * t_int) * 300) + ((4 * (n_dis * n_dis) -
(4 * dif_co * t_int)) * 300) + ((2 * dif_co * t_int)
+ (s * n_dis * t_int) * 300);
temp[i] = heat.tri(a, b, c, d, n);
Console.WriteLine("Temprature is {0}", i, temp[i].ToString());
}
}
}
}
спасибо было полезно – user3061003