Find the coordinates of a triangle whose Area = ( S / 2 ) | C ++ implementation of the approach ; Function to find the triangle with area = ( S / 2 ) ; Fix the two pairs of coordinates ; Find ( X3 , Y3 ) with integer coordinates ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; const long MAX = 1000000000 ; void findTriangle ( long S ) { long X1 = 0 , Y1 = 0 ; long X2 = MAX , Y2 = 1 ; long X3 = ( MAX - S % MAX ) % MAX ; long Y3 = ( S + X3 ) / MAX ; cout << " ( " << X1 << " , ▁ " << Y1 << " ) STRNEWLINE " ; cout << " ( " << X2 << " , ▁ " << Y2 << " ) STRNEWLINE " ; cout << " ( " << X3 << " , ▁ " << Y3 << " ) " ; } int main ( ) { long S = 4 ; findTriangle ( S ) ; return 0 ; }