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
using System ; using System . Collections ; class GFG { static final int N = 3 ; static ArrayList solve ( int [ ] v ) { ArrayList res = new ArrayList ( ) ; int all3 = v [ 0 ] + v [ 1 ] + v [ 2 ] ; res . Add ( all3 - v [ 1 ] * 2 ) ; res . Add ( all3 - v [ 2 ] * 2 ) ; res . Add ( all3 - v [ 0 ] * 2 ) ; return res ; } static void findVertex ( int [ ] xmid , int [ ] ymid ) { ArrayList V1 = solve ( xmid ) ; ArrayList V2 = solve ( ymid ) ; for ( int i = 0 ; i < 3 ; i ++ ) { Console . WriteLine ( V1 [ i ] + " ▁ " + V2 [ i ] ) ; } } public static void Main ( ) { int [ ] xmid = { 5 , 4 , 5 } ; int [ ] ymid = { 3 , 4 , 5 } ; findVertex ( xmid , ymid ) ; } }