I have an input array, and I initialize it.
Then I need to perform addition, subtraction, addition, or division operations with a certain element of the array.
Of course, nothing works if you simply refer to a specific element of the array and multiply it, for example, by 30.
Here's a torn piece of code, how can you redo it to make it work?

  • one
    specifically write what you want to do with the array, but do not post your matan listings ( - user205867
  • @ Otis666 I have a double matrix. I need to make calculations with ODA. array elements, as I described earlier - user204299
  • Opt. elements, it is not very clear (say better at what level of nesting they are and in what position, otherwise I’m not comfortable with so many matans) - user205867
  • 2
    And how is this, sorry for the expression, nonsense should work? if (Console.WriteLine(array2[4]) <= (30.0 *Console.WriteLine(array2[1]) + 30 * h_r)) ? - Max ZS
  • one
    Console.WriteLine does "output to the screen", you slapped it where necessary and where not necessary. Where you need to output - leave there, and where the calculations - remove, for example: q = 1 - 30 * (h_r + Console.WriteLine(array2[1])) / Console.WriteLine(array2[4]); Replace with q = 1 - 30 * (h_r + array2[1]) / array2[4]; etc. - i-one

1 answer 1

And in the end, after all the manipulations, you should get something like this.
PS did not check brackets.

  ..... double[] array2 = new double[] { 250.0, 10.0, 1.0, 70.0, 70.0, 1.0 }; if (array2[4] <= (30.0 * array2[1] + 30 * h_r)){ q = A_m = 0; Console.WriteLine($"q= {q.ToString()}\r\nA_m= {A_m.ToString()} дБ"); } else { q = 1 - 30 * (h_r + array2[1]) / array2[4]; Console.WriteLine($"q= {q.ToString()} "); } double dAr4elem = (1 - Math.Exp(-array2[4] / 50)); a_h_r = 1.5 + 3.0 * Math.Exp(-0.12 * Math.Sqrt(h_r - 5)) * (dAr4elem + 5.7 * Math.Exp(-0.09 * Math.Sqrt(h_r)) * (1 - Math.Exp(-2.8 * Math.Pow(10, -6) - Math.Sqrt(array2[4])))); a_h_s = 1.5 + 3.0 * Math.Exp(-0.12 * Math.Sqrt(array2[1] - 5)) * (dAr4elem + 5.7 * Math.Exp(-0.09 * Math.Sqrt(array2[1])) * (1 - Math.Exp(-2.8 * Math.Pow(10, -6) - Math.Sqrt(array2[4])))); b_h_s = 1.5 + 8.6 * Math.Exp(-0.09 * Math.Sqrt(array2[1])) * dAr4elem; b_h_r = 1.5 + 8.6 * Math.Exp(-0.09 * Math.Sqrt(h_r)) * dAr4elem; c_h_s = 1.5 + 14 * Math.Exp(-0.46 * Math.Sqrt(array2[1])) * dAr4elem; c_h_r = 1.5 + 14 * Math.Exp(-0.46 * Math.Sqrt(h_r)) * dAr4elem; d_h_s = 1.5 + 5 * Math.Exp(-0.9 * Math.Sqrt(array2[1])) * dAr4elem; d_h_r = 1.5 + 5 * Math.Exp(-0.9 * Math.Sqrt(h_r)) * dAr4elem; Console.WriteLine($"a_h_r {a_h_r.ToString()}" + $"\r\na_h_s= {a_h_s.ToString()}" + $"\r\nb_h_s= {b_h_s.ToString()}" + $"\r\nb_h_r= {b_h_r.ToString()}" + $"\r\nc_h_s= {c_h_s.ToString()}" + $"\r\nc_h_r= {c_h_r.ToString()}" + $"\r\nd_h_s= {d_h_s.ToString()}" + $"\r\nd_h_r= {d_h_r.ToString()}"); for (int i = 0; i < 8; i++) { if (i == 0) //63 { A_m = -3 * q; A_s = -1.5; A_r = -1.5; A_gr = A_m + A_r + A_s;// Затухание из-за влияния земли. double A_div = ((20 * Math.Log10(array2[3] / d_0)) + 11);// Затухание из-за геометрической дивергенции (из-за расхождения энергии при излучении в свободное пространство). double A_atm = Acoustics.a * array2[3] / 1000;// Затухание из-за звукопоглощения атмосферой [дБ]. A = A_gr + A_div + A_atm; Console.WriteLine($"A_m= {A_m.ToString()} дБ" + $"\r\nA_s= {A_s.ToString()} дБ" + $"\r\nA_r= {A_r.ToString()} дБ" + $"\r\nA_gr= {A_gr.ToString()} дБ" + $"\r\nA_div= {A_div.ToString()} дБ" + $"\r\nA_atm= {A_atm.ToString()} дБ" + $"\r\nA= {A.ToString()} дБ"); } .... 
  • one
    Did it really work? O_o But on the other hand it is good. Magic buttons from the side of the answer, the best reward - LamerXaKer