Count of Equilateral Triangles of unit length possible from a given Hexagon | C # program to implement the above approach ; Function to calculate the the number of Triangles possible ; Driver Code ; Regular Hexagon ; Irregular Hexagon
using System ; class GFG { static int calculateTriangles ( int [ ] sides ) { double count = Math . Pow ( sides [ 0 ] + sides [ 1 ] + sides [ 2 ] , 2 ) ; count -= Math . Pow ( sides [ 0 ] , 2 ) ; count -= Math . Pow ( sides [ 2 ] , 2 ) ; count -= Math . Pow ( sides [ 4 ] , 2 ) ; return ( int ) ( count ) ; } public static void Main ( String [ ] args ) { int [ ] sides = { 1 , 1 , 1 , 1 , 1 , 1 } ; Console . Write ( ( calculateTriangles ( sides ) ) + " STRNEWLINE " ) ; int [ ] sides1 = { 2 , 2 , 1 , 3 , 1 , 2 } ; Console . Write ( ( calculateTriangles ( sides1 ) ) + " STRNEWLINE " ) ; } }