Текст программы с комментриями #pragma endregion // минимизируемая функция private: double f(double x) { return 2 * Math::Pow(x - 3, 2) + Math::Exp(Math::Pow(x, 2) / 2); //return 0.2 * x * Math::Log(x) + Math::Pow(x - 2.3, 2); } // вычисление производной функции private: double df(double x) { double dx = 0.001; return (f(x + dx) - f(x - dx)) / (2 * dx); } // функция реализует метод наискорейшего спуска private: void descent(double x, double eps) { int k = 0; double h = 0.7; for (; ; ) { double y = df(x); double z = Math::Sqrt(Math::Pow(y, 2)); if (z < eps) { // добавить строку в таблицу dataGridView1->Rows->Add(); dataGridView1->Rows[k - 1]->Cells[0]->Value = k.ToString(); // Math::Round() - округление, 2й аргумент - число знаков после запятой dataGridView1->Rows[k - 1]->Cells[1]->Value = Math::Round(x, 6).ToString(); dataGridView1->Rows[k - 1]->Cells[2]->Value = Math::Round(f(x), 6).ToString(); // записать результаты в текстовые поля textBox3->Text = Math::Round(x, 6).ToString(); textBox4->Text = Math::Round(f(x), 6).ToString(); break; } else { for (; ; ) { double f_1 = f(x); double x_1 = x - h * y; double f_2 = f(x_1); if (f_2 < f_1) { k++; x = x_1; // добавить строку в таблицу dataGridView1->Rows->Add(); dataGridView1->Rows[k - 1]->Cells[0]->Value = k.ToString(); dataGridView1->Rows[k - 1]->Cells[1]->Value = Math::Round(x, 6).ToString(); dataGridView1->Rows[k - 1]->Cells[2]->Value = Math::Round(f(x), 6).ToString(); break; } else { h *= 0.7; } } } } } // рисование фукции private: void draw(double a, double b) { // очистка поля chart1->Series[0]->Points->Clear(); double h = 0.001; for (double x = a; x <= b; x += h) { // добавить точку на график chart1->Series[0]->Points->AddXY(x, f(x)); } } // обработка события при нажатии на кнопку private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { double x, eps, a, b; // обработка исключения try { // получения данных из полей x = Convert::ToDouble(textBox1->Text); eps = Convert::ToDouble(textBox2->Text); a = Convert::ToDouble(textBox5->Text); b = Convert::ToDouble(textBox6->Text); if (a >= b) { // сообщение об ошибке MessageBox::Show("Введите корректный интервал!"); } else { // обнулить число строк dataGridView1->RowCount = 0; // вызов функции descent(x, eps); // нарисовать график функции draw(a, b); } } catch (...) { // сообщение об ошибке MessageBox::Show("Введите корректные данные!"); } }
Standard input is empty
prog.cpp:1:1: error: stray '\320' in program Текст программы с комментриями ^ prog.cpp:1:1: error: stray '\242' in program prog.cpp:1:1: error: stray '\320' in program prog.cpp:1:1: error: stray '\265' in program prog.cpp:1:1: error: stray '\320' in program prog.cpp:1:1: error: stray '\272' in program prog.cpp:1:1: error: stray '\321' in program prog.cpp:1:1: error: stray '\201' in program prog.cpp:1:1: error: stray '\321' in program prog.cpp:1:1: error: stray '\202' in program prog.cpp:1:1: error: stray '\320' in program prog.cpp:1:1: error: stray '\277' in program prog.cpp:1:1: error: stray '\321' in program prog.cpp:1:1: error: stray '\200' in program prog.cpp:1:1: error: stray '\320' in program prog.cpp:1:1: error: stray '\276' in program prog.cpp:1:1: error: stray '\320' in program prog.cpp:1:1: error: stray '\263' in program prog.cpp:1:1: error: stray '\321' in program prog.cpp:1:1: error: stray '\200' in program prog.cpp:1:1: error: stray '\320' in program prog.cpp:1:1: error: stray '\260' in program prog.cpp:1:1: error: stray '\320' in program prog.cpp:1:1: error: stray '\274' in program prog.cpp:1:1: error: stray '\320' in program prog.cpp:1:1: error: stray '\274' in program prog.cpp:1:1: error: stray '\321' in program prog.cpp:1:1: error: stray '\213' in program prog.cpp:1:1: error: stray '\321' in program prog.cpp:1:1: error: stray '\201' in program prog.cpp:1:1: error: stray '\320' in program prog.cpp:1:1: error: stray '\272' in program prog.cpp:1:1: error: stray '\320' in program prog.cpp:1:1: error: stray '\276' in program prog.cpp:1:1: error: stray '\320' in program prog.cpp:1:1: error: stray '\274' in program prog.cpp:1:1: error: stray '\320' in program prog.cpp:1:1: error: stray '\274' in program prog.cpp:1:1: error: stray '\320' in program prog.cpp:1:1: error: stray '\265' in program prog.cpp:1:1: error: stray '\320' in program prog.cpp:1:1: error: stray '\275' in program prog.cpp:1:1: error: stray '\321' in program prog.cpp:1:1: error: stray '\202' in program prog.cpp:1:1: error: stray '\321' in program prog.cpp:1:1: error: stray '\200' in program prog.cpp:1:1: error: stray '\320' in program prog.cpp:1:1: error: stray '\270' in program prog.cpp:1:1: error: stray '\321' in program prog.cpp:1:1: error: stray '\217' in program prog.cpp:1:1: error: stray '\320' in program prog.cpp:1:1: error: stray '\274' in program prog.cpp:1:1: error: stray '\320' in program prog.cpp:1:1: error: stray '\270' in program prog.cpp:4:2: error: expected unqualified-id before 'private' private: double f(double x) { ^ prog.cpp:11:2: error: expected unqualified-id before 'private' private: double df(double x) { ^ prog.cpp:18:2: error: expected unqualified-id before 'private' private: void descent(double x, double eps) { ^
Standard output is empty