There is a cycle for DataGridViev with a sequential calculation, it is necessary that he first counts a certain number of times by one formula, then once by another and at the end of the 3rd formula also a certain number of times Now it looks like this, but I I know that this is wrong, tell me how it should be

double z_pnd = Convert.ToDouble(textBox4.Text), z_pvd = Convert.ToDouble(textBox3.Text), t_kond = Convert.ToDouble(textBox8.Text), t_dear = Convert.ToDouble(textBox9.Text), t_oe = Convert.ToDouble(textBox10.Text), t_egu = Convert.ToDouble(textBox11.Text), z = Convert.ToDouble(textBox2.Text), alfa = 0.9, tp_pereddear = t_dear - 10, t_nach = Convert.ToDouble(textBox6.Text), p_pg = Convert.ToDouble(textBox7.Text), t_pv = ((t_nach - t_kond - t_oe - t_egu) / (z + 1)), t_pvopt = t_nach - t_pv, t_pvek = alfa * (t_pvopt - t_kond) + t_kond, delt_pvd = (t_pvek - t_dear) / z_pvd, delt_pnd = (tp_pereddear - t_kond - t_oe - t_egu) / z_pnd; textBox15.Text = delt_pvd.ToString(); textBox16.Text = delt_pnd.ToString(); int gg = Convert.ToInt32(textBox2.Text); dataGridView2.RowCount = gg; double yBasepnd = t_kond + t_oe + t_egu + delt_pnd; double yBasepvd = t_kond + t_oe + t_egu + t_pv; double[] y = new double[gg]; for (int i = 0; i < z_pnd; i++) { dataGridView2.Rows[i].Cells[0].Value = y[i].ToString(); y[i] = yBasepnd + delt_pnd * i; } for (int i = z_pnd) { dataGridView2.Rows[i].Cells[0].Value = y[i].ToString(); y[i] = t_dear; } for (int i = z_pnd+1; i < gg; i++) { dataGridView2.Rows[i].Cells[0].Value = y[i].ToString(); y[i] = yBasepvd + delt_pvd * (i-z_pnd-1); } 
  • From your text, the code cannot be said exactly what you want to do. Who counted? What are the formulas? - Ev_Hyper
  • z_pnd-number in times for the calculation of this formula: y [i] = yBasepnd + delt_pnd * i; Then the value is: y [i] = t_dear; Then z_pvd- number of times for the calculation by the formula y [i] = yBasepvd + delt_pvd * (i-z_pnd-1) - Michael K
  • 2
    Maybe still read about the cycles in C #? - Igor
  • I read, watched the video, nothing sensible comes out, then errors, then the impossibility of conversion, like I need I did not find - Michael K
  • 2
    I suggest you take any textbook and read the basics ... because without an understanding of such elementary things you cannot program normally. - Ev_Hyper

1 answer 1

 int i; for (i = 0; i < z_pnd; i++) { y[i] = yBasepnd + delt_pnd * i; dataGridView2.Rows[i].Cells[0].Value = y[i].ToString(); } y[i] = t_dear; dataGridView2.Rows[i].Cells[0].Value = y[i].ToString(); for (i = i + 1; i < gg; i++) { y[i] = yBasepvd + delt_pvd * (i-z_pnd-1); dataGridView2.Rows[i].Cells[0].Value = y[i].ToString(); } 
  • Cannot convert double to int - Michael K
  • one
    @ MikhailK Here you sit in front of the computer and get this error. Does it not occur to the search engine to read: "C # convert double to int"? - Igor
  • Many thanks - Michael By