-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
35 lines (33 loc) · 1.24 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include "coordinate.h"
int main()
{
std::vector<coordinate::Coordinate> coordinateVector = {{4,4}, {8,4}, {6,4}, {2, 6}, {10, 6}};
auto maximumX = (max_element(coordinateVector.begin(), coordinateVector.end()))->x;
auto mininalX = (min_element(coordinateVector.begin(), coordinateVector.end()))->x;
auto middleX = (maximumX + mininalX) / static_cast<coordinate::CoordinateType>(2);
std::unordered_set<coordinate::Coordinate, coordinate::CoordinateHash> coordinateMap(
coordinateVector.begin(),
coordinateVector.end());
bool verticalLineExists = true;
for (const auto& point : coordinateMap)
{
if (coordinateMap.find({coordinate::CoordinateType{2} * middleX - point.x, point.y}) == coordinateMap.end())
{
verticalLineExists = false;
break;
}
}
if (verticalLineExists)
{
std::cout << "Line exists, x = " << +middleX << std::endl;
}
else
{
std::cout << "Line doesn't exist" << std::endl;
}
return 0;
}