Untitled

mail@pastecode.io avatar
unknown
c_cpp
17 days ago
679 B
0
Indexable
Never
#include <iostream>
#include <fstream>

void make_points(float l1, float l2, int size, std::pair<float, float>*& points) {
	float step = (l2 - l1) / size;
	float y{};
	float distance = l2 - l1;
	int i = 0;
	for (int x = -(distance/2); x < (distance / 2) && i < 100; x += step) {
		y = x * x + 5 * x - 52;
		points[i] = std::make_pair(x, y);
		i++;
	}
}
int main()
{
	std::ofstream out("input.txt");
	int size = 100;
	std::pair<float,float>* points = new std::pair<float, float>[size];
	make_points(0, 100, size,points);
	for (int i = 0; i < size;i++) {
		out << points[i].first << " " << points[i].second << '\n';
	}

	delete[] points;
	out.close();
}
Leave a Comment