Дополнен 1 год назад
int main() {
setlocale(LC_ALL, "");
float start, end;
cout << "введите начальное значение интервала: ";
cin >> start;
cout << "введите конечное значение интервала: ";
cin >> end;
cout << "f1(x) = pow(x + exp(x), 1 / 15)" << endl;
cout << "f2(x) = pow(x + exp(x), 1 / 25)" << endl;
Дополнен 1 год назад
printtable(start, end);
sf::RenderWindow window(sf::VideoMode(width, height), "график функции");
sf::VertexArray x_axis(sf::Lines, 2);
x_axis[0].position = sf::Vector2f(0, height / 2);
x_axis[1].position = sf::Vector2f(width, height / 2);
x_axis[0].color = sf::Color::Black;
x_axis[1].color = sf::Color::Black;
sf::VertexArray y_axis(sf::Lines, 2);
y_axis[0].position = sf::Vector2f(width / 2, 0);
y_axis[1].position = sf::Vector2f(width / 2, height);
y_axis[0].color = sf::Color::Black;
y_axis[1].color = sf::Color::Black;
sf::VertexArray graph1(sf::LineStrip, width);
for (int i = 0; i < width; ++i) {
float x = i - width / 2;
float y1 = function1(x);
graph1[i].position = sf::Vector2f(x + width / 2, -y1 + height / 2);
graph1[i].color = sf::Color::Red;
}
sf::VertexArray graph2(sf::LineStrip, width);
for (int i = 0; i < width; ++i) {
float x = i - width / 2;
float y2 = function2(x);
graph2[i].position = sf::Vector2f(x + width / 2, -y2 + height / 2);
graph2[i].color = sf::Color::Green;
}
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
window.close();
}
window.clear(sf::Color::White);
window.draw(x_axis);
window.draw(y_axis);
window.draw(graph1);
window.draw(graph2);
window.display();
}
return 0;
}