Untitled

Anonymous
c_cpp
02/17/2026 1:42 PM
628 B
11
Indexable
#include <array>
#include <iostream>

struct Point
{
	double x;
	double y;
};

int main()
{
	std::array< Point, 5 > points = {
		Point( 2.5, 7.5 ), Point( 3.6, 6.5 ),
		Point( 2.9, 8.7 ), Point( 3.4, 7.5 ),
		Point( 2.1, 7.1 )
	};

	for( Point p : points )
	{
		std::cout << p.x << ", " << p.y << '\n';
	}

	std::cout << '\n';

	for( int i = 0; i < points.size(); ++i )
	{
		std::cout << points[ i ].x << ", " << points[ i ].y << '\n';
	}
}
Editor is loading...
Leave a Comment