60 lines
915 B
C++
60 lines
915 B
C++
#include <iostream>
|
|
#include <fstream>
|
|
#include <cmath>
|
|
|
|
using namespace std;
|
|
|
|
|
|
ifstream input_stream;
|
|
|
|
|
|
struct Point
|
|
{
|
|
double x;
|
|
double y;
|
|
Point(double i, double j): x(i), y(j) {
|
|
|
|
}
|
|
};
|
|
|
|
|
|
double getDistance(Point *p1, Point *p2) {
|
|
double x_distance = abs(p1 -> x - p2 -> x);
|
|
double y_distance = abs(p1 -> y - p2 -> y);
|
|
return pow(x_distance, 2) + pow(y_distance, 2);
|
|
}
|
|
|
|
|
|
|
|
uint16_t findSides(Point *points[3]) {
|
|
double d1 = getDistance(points[0], points[1]);
|
|
double d2 = getDistance(points[0], points[2]);
|
|
double d3 = getDistance(points[1], points[2]);
|
|
|
|
if (d1 == d2 && d1 == d3) {
|
|
return 3;
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
input_stream.open("input.txt");
|
|
|
|
Point *points[3];
|
|
|
|
for (uint8_t i = 0; i < 3; i++) {
|
|
double tmp_x, tmp_y;
|
|
input_stream >> tmp_x;
|
|
input_stream >> tmp_y;
|
|
|
|
points[i] = new Point(tmp_x, tmp_y);
|
|
}
|
|
|
|
cout << findSides(points) << endl;
|
|
|
|
input_stream.close();
|
|
return 0;
|
|
} |