private void ReplaceNegativeVariables() { int j = 1; bool isChanged = false; for (int i = 1; i < isNonNegative.Count; i++) { if (!isNonNegative[i]) { isChanged = true; var oldName = varNames[i - 1]; A.ReplaceVariableWithSub(i); varNames[i - 1] = $"x'{j}"; ReplaceDataGridColumn(dataGridView1, $"x'{j}", i - 1, Color.LightGray); varNames.Insert(i, $"x''{j}"); InsertDataGridColumn(dataGridView1, $"x''{j}", i, Color.LightGray); C.InsertAndReplace(i); textBox1.Text += $"Переменная {oldName} < 0. Выполним замену:" + Environment.NewLine + $"\t{oldName} = {varNames[i - 1]} - {varNames[i]}" + Environment.NewLine + Environment.NewLine; isNonNegative[i] = true; isNonNegative.Insert(i++, true); } j++; } if (isChanged) { PrintTargetFunction(); PrintLimits(); } }