Find coordinates of the triangle given midpoint of each side | C ++ program to find coordinate of the triangle given midpoint of each side ; Return after solving the equations and finding the vertices coordinate . ; Finding sum of all three coordinate . ; Solving the equation . ; Finds vertices of a triangles from given middle vertices . ; Find X coordinates of vertices . ; Find Y coordinates of vertices . ; Output the solution . ; Driver code
#include <bits/stdc++.h> NEW_LINE #define N  3 NEW_LINE using namespace std ; vector < int > solve ( int v [ ] ) { vector < int > res ; int all3 = v [ 0 ] + v [ 1 ] + v [ 2 ] ; res . push_back ( all3 - v [ 1 ] * 2 ) ; res . push_back ( all3 - v [ 2 ] * 2 ) ; res . push_back ( all3 - v [ 0 ] * 2 ) ; return res ; } void findVertex ( int xmid [ ] , int ymid [ ] ) { vector < int > V1 = solve ( xmid ) ; vector < int > V2 = solve ( ymid ) ; for ( int i = 0 ; i < 3 ; i ++ ) cout << V1 [ i ] << " ▁ " << V2 [ i ] << endl ; } int main ( ) { int xmid [ N ] = { 5 , 4 , 5 } ; int ymid [ N ] = { 3 , 4 , 5 } ; findVertex ( xmid , ymid ) ; return 0 ; }