Положение вершин треугольника на плоскости - C#
Формулировка задачи:
public struct point
{
public double x;
public double y;
public point(double x, double y) { this.x = x; this.y = y; }
public override string ToString()
{
return $"x = {x} y = {y}";
}
}
public struct triangle
{
public point A { get; set; }
public point B { get; set; }
public point C { get; set; }
public point top { get; set; }
public point left { get; set; }
public point right { get; set; }
public point bottom { get; set; }
public triangle(point A, point B, point C)
{
this.A = A;
this.B = B;
this.C = C;
//this.top = ?;
//this.left = ?;
//this.right = ?;
//this.bottom = ?;
}
}Решение задачи: «Положение вершин треугольника на плоскости»
textual
Листинг программы
if (A.y > B.y && A.y > C.y) this.top = A;
else if (B.y > A.y && B.y > C.y) this.top = B;
else this.top = C;
if (B.x < C.x) { this.left = B; this.right = C; }
else { this.left = C; this.right = B; }
if (B.y < C.y) this.bottom = B;
else this.bottom = C;