codeparrot/xlcost-text-to-code huggingface dataset:
Count number of triangles cut by the given horizontal and vertical line segments | C # program for the above approach ; Store the minimum and maximum X and Y coordinates ; Function to convert String to int ; Function to print the number of triangles cut by each line segment ; Initialize Structure ; Find maximum and minimum X and Y coordinates for each triangle ; Minimum X ; Maximum X ; Minimum Y ; Maximum Y ; Traverse each cut from 0 to M - 1 ; Store number of triangles cut ; Extract value from the line segment String ; If cut is made on X - axis ; Check for each triangle if x lies b / w max and min X coordinates ; If cut is made on Y - axis ; Check for each triangle if y lies b / w max and min Y coordinates ; Print answer for ith cut ; Driver Code ; Given coordinates of triangles ; Given cuts of lines ; Function Call
using System ; class GFG { public class Tri { public int MinX , MaxX , MinY , MaxY ; } ; static int StringtoInt ( String s ) { return Int32 . Parse ( s ) ; } static int min ( int a , int b , int c ) { return Math . Min ( a , Math . Min ( b , c ) ) ; } static int max ( int a , int b , int c ) { return Math . Max ( a , Math . Max ( b , c ) ) ; } static void TriangleCuts ( int [ , ] Triangle , String [ ] Cuts , int N , int M , int COL ) { Tri [ ] Minimized = new Tri [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { Minimized [ i ] = new Tri ( ) ; Minimized [ i ] . MaxX = 0 ; Minimized [ i ] . MaxY = 0 ; Minimized [ i ] . MinX = 0 ; Minimized [ i ] . MinY = 0 ; } for ( int i = 0 ; i < N ; i ++ ) { int x1 = Triangle [ i , 0 ] ; int y1 = Triangle [ i , 1 ] ; int x2 = Triangle [ i , 2 ] ; int y2 = Triangle [ i , 3 ] ; int x3 = Triangle [ i , 4 ] ; int y3 = Triangle [ i , 5 ] ; Minimized [ i ] . MinX = min ( x1 , x2 , x3 ) ; Minimized [ i ] . MaxX = max ( x1 , x2 , x3 ) ; Minimized [ i ] . MinY = min ( y1 , y2 , y3 ) ; Minimized [ i ] . MaxY = max ( y1 , y2 , y3 ) ; } for ( int i = 0 ; i < M ; i ++ ) { String Cut = Cuts [ i ] ; int CutCount = 0 ; int CutVal = StringtoInt ( Cut . Substring ( 2 , Cut . Length - 2 ) ) ; if ( Cut [ 0 ] == ' X ' ) { for ( int j = 0 ; j < N ; j ++ ) { if ( ( Minimized [ j ] . MinX ) < ( CutVal ) & & ( Minimized [ j ] . MaxX ) > ( CutVal ) ) { CutCount ++ ; } } } else if ( Cut [ 0 ] == ' Y ' ) { for ( int j = 0 ; j < N ; j ++ ) { if ( ( Minimized [ j ] . MinY ) < ( CutVal ) & & ( Minimized [ j ] . MaxY ) > ( CutVal ) ) { CutCount ++ ; } } } Console . Write ( CutCount + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ , ] Triangle = { { 0 , 2 , 2 , 9 , 8 , 5 } , { 5 , 0 , 6 , 3 , 7 , 0 } } ; int N = Triangle . GetLength ( 0 ) ; int COL = 6 ; String [ ] Cuts = { " X = 2" , " Y = 2" , " Y = 9" } ; int M = Cuts . Length ; TriangleCuts ( Triangle , Cuts , N , M , COL ) ; } }
Count rectangles generated in a given rectangle by lines drawn parallel to X and Y axis from a given set of points | C # program to implement the above approach ; Function to get the count of ractangles ; Store distinct horizontal lines ; Store distinct Vertical lines ; Insert horizontal line passing through 0 ; Insert vertical line passing through 0. ; Insert horizontal line passing through rectangle [ 3 , 0 ] ; Insert vertical line passing through rectangle [ 3 , 1 ] ; Insert all horizontal and vertical lines passing through the given array ; Insert all horizontal lines ; Insert all vertical lines ; Driver Code
using System ; using System . Collections . Generic ; class GFG { public static int cntRect ( int [ , ] points , int N , int [ , ] rectangle ) { HashSet < int > cntHor = new HashSet < int > ( ) ; HashSet < int > cntVer = new HashSet < int > ( ) ; cntHor . Add ( 0 ) ; cntVer . Add ( 0 ) ; cntHor . Add ( rectangle [ 3 , 0 ] ) ; cntVer . Add ( rectangle [ 3 , 1 ] ) ; for ( int i = 0 ; i < N ; i ++ ) { cntHor . Add ( points [ i , 0 ] ) ; cntVer . Add ( points [ i , 1 ] ) ; } return ( cntHor . Count - 1 ) * ( cntVer . Count - 1 ) ; } public static void Main ( String [ ] args ) { int [ , ] rectangle = { { 0 , 0 } , { 0 , 5 } , { 5 , 0 } , { 5 , 5 } } ; int [ , ] points = { { 1 , 2 } , { 3 , 4 } } ; int N = points . GetLength ( 0 ) ; Console . WriteLine ( cntRect ( points , N , rectangle ) ) ; } }
Count squares possible from M and N straight lines parallel to X and Y axis respectively | C # program for the above approach ; Function to count all the possible squares with given lines parallel to both the X and Y axis ; Stores the count of all possible distances in X [ ] & Y [ ] respectively ; Find distance between all pairs in the array X [ ] ; Add the count to m1 ; Find distance between all pairs in the array Y [ ] ; Add the count to m2 ; Find sum of m1 [ i ] * m2 [ i ] for same distance ; Find current count in m2 ; Add to the total count ; Return the final count ; Driver Code ; Given lines ; Function call
using System ; using System . Collections . Generic ; class GFG { static int numberOfSquares ( int [ ] X , int [ ] Y , int N , int M ) { Dictionary < int , int > m1 = new Dictionary < int , int > ( ) ; Dictionary < int , int > m2 = new Dictionary < int , int > ( ) ; int i , j , ans = 0 ; for ( i = 0 ; i < N ; i ++ ) { for ( j = i + 1 ; j < N ; j ++ ) { int dist = Math . Abs ( X [ i ] - X [ j ] ) ; if ( m1 . ContainsKey ( dist ) ) m1 [ dist ] ++ ; else m1 . Add ( dist , 1 ) ; } } for ( i = 0 ; i < M ; i ++ ) { for ( j = i + 1 ; j < M ; j ++ ) { int dist = Math . Abs ( Y [ i ] - Y [ j ] ) ; if ( m2 . ContainsKey ( dist ) ) m2 [ dist ] ++ ; else m2 . Add ( dist , 1 ) ; } } foreach ( KeyValuePair < int , int > entry in m1 ) { if ( m2 . ContainsKey ( entry . Key ) ) { ans += ( entry . Value * m2 [ entry . Key ] ) ; } } return ans ; } public static void Main ( ) { int [ ] X = { 1 , 3 , 7 } ; int [ ] Y = { 2 , 4 , 6 , 1 } ; int N = X . Length ; int M = Y . Length ; Console . WriteLine ( numberOfSquares ( X , Y , N , M ) ) ; } }
Program to calculate area of a parallelogram | C # program for the above approach ; Function to return the area of parallelogram using sides and angle at the intersection of diagonal ; Calculate area of parallelogram ; Return the answer ; Function to return the area of parallelogram using sides and angle at the intersection of sides ; Calculate area of parallelogram ; Return the answer ; Function to return the area of parallelogram using diagonals and angle at the intersection of diagonals ; Calculate area of parallelogram ; Return the answer ; Driver code ; Given diagonal and angle ; Function call ; Print the area
using System ; class GFG { static double Area_Parallelogram1 ( int a , int b , int theta ) { double area = ( Math . Abs ( Math . Tan ( ( theta * Math . PI ) / 180 ) ) / 2 ) * Math . Abs ( a * a - b * b ) ; return area ; } static double Area_Parallelogram2 ( int a , int b , int gamma ) { double area = ( Math . Abs ( Math . Sin ( ( gamma * Math . PI ) / 180 ) ) ) * Math . Abs ( a * b ) ; return area ; } static double Area_Parallelogram3 ( int d1 , int d2 , int theta ) { double area = ( Math . Abs ( Math . Sin ( ( theta * Math . PI ) / 180 ) ) / 2 ) * Math . Abs ( d1 * d2 ) ; return area ; } public static void Main ( String [ ] args ) { int d1 = 3 ; int d2 = 5 ; int theta = 90 ; double area = Area_Parallelogram3 ( d1 , d2 , theta ) ; Console . Write ( " { 0 : F2 } " , area ) ; } }
Count squares of size K inscribed in a square of size N | C # implementation of the above approach ; Function to calculate the number of squares of size K in a square of size N ; Stores the number of squares ; Driver Code ; Size of the bigger square ; Size of smaller square
using System ; class GFG { static int No_of_squares ( int N , int K ) { int no_of_squares = 0 ; no_of_squares = ( N - K + 1 ) * ( N - K + 1 ) ; return no_of_squares ; } public static void Main ( String [ ] args ) { int N = 5 ; int K = 3 ; Console . Write ( No_of_squares ( N , K ) ) ; } }
Count cubes of size K inscribed in a cube of size N | C # implementation of the above approach ; Function to find the number of the cubes of the size K ; Stores the number of cubes ; Stores the number of cubes of size k ; Driver Code ; Size of the bigger cube ; Size of the smaller cube
using System ; class GFG { static int No_of_cubes ( int N , int K ) { int No = 0 ; No = ( N - K + 1 ) ; No = ( int ) Math . Pow ( No , 3 ) ; return No ; } public static void Main ( ) { int N = 5 ; int K = 2 ; Console . Write ( No_of_cubes ( N , K ) ) ; } }
Count of smaller rectangles that can be placed inside a bigger rectangle | C # program for the above approach ; Function to count smaller rectangles within the larger rectangle ; If the dimension of the smaller rectangle is greater than the bigger one ; Return the number of smaller rectangles possible ; Driver Code ; Dimension of bigger rectangle ; Dimension of smaller rectangle ; Function call
using System ; class GFG { static int No_of_rectangles ( int L , int B , int l , int b ) { if ( ( l > L ) || ( b > B ) ) { return - 1 ; } else { return ( L - l + 1 ) * ( B - b + 1 ) ; } } public static void Main ( String [ ] args ) { int L = 5 , B = 3 ; int l = 4 , b = 1 ; Console . Write ( No_of_rectangles ( L , B , l , b ) ) ; } }
Program To Check whether a Triangle is Equilateral , Isosceles or Scalene | C # program for the above approach ; Function to check if the triangle is equilateral or isosceles or scalene ; Check for equilateral triangle ; Check for isosceles triangle ; Otherwise scalene triangle ; Driver Code ; Given sides of triangle ; Function call
using System ; class GFG { static void checkTriangle ( int x , int y , int z ) { if ( x == y && y == z ) Console . WriteLine ( " Equilateral ▁ Triangle " ) ; else if ( x == y y == z z == x ) Console . WriteLine ( " Isosceles ▁ Triangle " ) ; else Console . WriteLine ( " Scalene ▁ Triangle " ) ; } public static void Main ( ) { int x = 8 , y = 7 , z = 9 ; checkTriangle ( x , y , z ) ; } }
Find the remaining vertices of a square from two given vertices | C # program for the above approach ; Function to find the remaining vertices of a square ; Check if the x - coordinates are equal ; Check if the y - coordinates are equal ; If the the given coordinates forms a diagonal of the square ; Otherwise ; Square does not exist ; Driver Code ; Given two vertices
using System ; class GFG { static void findVertices ( int x1 , int y1 , int x2 , int y2 ) { if ( x1 == x2 ) { Console . Write ( ( x1 + y2 - y1 ) + " , ▁ " + y1 + " STRNEWLINE " ) ; Console . Write ( ( x2 + y2 - y1 ) + " , ▁ " + y2 ) ; } else if ( y1 == y2 ) { Console . Write ( x1 + " , ▁ " + ( y1 + x2 - x1 ) + " STRNEWLINE " ) ; Console . Write ( x2 + " , ▁ " + ( y2 + x2 - x1 ) ) ; } else if ( Math . Abs ( x2 - x1 ) == Math . Abs ( y2 - y1 ) ) { Console . Write ( x1 + " , ▁ " + y2 + " STRNEWLINE " ) ; Console . Write ( x2 + " , ▁ " + y1 ) ; } else Console . Write ( " - 1" ) ; } public static void Main ( String [ ] args ) { int x1 = 1 , y1 = 2 ; int x2 = 3 , y2 = 4 ; findVertices ( x1 , y1 , x2 , y2 ) ; } }
Find the area of rhombus from given Angle and Side length | C # Program to calculate area of rhombus from given angle and side length ; Function to return the area of rhombus using one angle and side . ; Driver Code ; Function Call ; Print the readonly answer
using System ; class GFG { static readonly double RADIAN = 0.01745329252 ; static double Area_of_Rhombus ( int a , int theta ) { double area = ( a * a ) * Math . Sin ( ( RADIAN * theta ) ) ; return area ; } public static void Main ( String [ ] args ) { int a = 4 ; int theta = 60 ; double ans = Area_of_Rhombus ( a , theta ) ; Console . Write ( " { 0 : F2 } " , ans ) ; } }
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 " ) ; } }
Length of diagonal of a parallelogram using adjacent sides and angle between them | C # program to find length Of diagonal of a parallelogram Using sides and angle between them . ; Function to return the length Of diagonal of a parallelogram using sides and angle between them . ; Driver Code ; Given sides ; Given angle ; Function call ; Print the readonly answer
using System ; class GFG { static double Length_Diagonal ( int a , int b , double theta ) { double diagonal = Math . Sqrt ( ( Math . Pow ( a , 2 ) + Math . Pow ( b , 2 ) ) - 2 * a * b * Math . Cos ( theta * ( Math . PI / 180 ) ) ) ; return diagonal ; } public static void Main ( String [ ] args ) { int a = 3 ; int b = 5 ; double theta = 45 ; double ans = Length_Diagonal ( a , b , theta ) ; Console . Write ( " { 0 : F2 } " , ans ) ; } }
Maximum number of tiles required to cover the floor of given size using 2 x1 size tiles | C # program for the above approach ; Function to find the maximum number of tiles required to cover the floor of size m x n using 2 x 1 size tiles ; Print the answer ; Driver code ; Given M and N ; Function call
using System ; class GFG { static void maximumTiles ( int n , int m ) { Console . WriteLine ( ( m * n ) / 2 ) ; } public static void Main ( String [ ] args ) { int M = 3 ; int N = 4 ; maximumTiles ( N , M ) ; } }
Length of a Diagonal of a Parallelogram using the length of Sides and the other Diagonal | C # Program to implement the above approach ; Function to calculate the length of the diagonal of a parallelogram using two sides and other diagonal ; Driver Code ; Function Call ; Print the readonly answer
using System ; class GFG { static float Length_Diagonal ( int a , int b , int d ) { float diagonal = ( float ) Math . Sqrt ( 2 * ( ( a * a ) + ( b * b ) ) - ( d * d ) ) ; return diagonal ; } public static void Main ( String [ ] args ) { int A = 10 ; int B = 30 ; int D = 20 ; float ans = Length_Diagonal ( A , B , D ) ; Console . Write ( " { 0 : F1 } " , ans ) ; } }
Length of Diagonals of a Cyclic Quadrilateral using the length of Sides . | C # Program to implement the above approach ; Function to calculate the length of diagonals of a cyclic quadrilateral ; Driver Code ; Function Call ; Print the readonly answer
using System ; using System . Collections . Generic ; class GFG { static List < float > Diagonals ( int a , int b , int c , int d ) { List < float > ans = new List < float > ( ) ; ans . Add ( ( float ) Math . Sqrt ( ( ( a * c ) + ( b * d ) ) * ( ( a * d ) + ( b * c ) ) / ( ( a * b ) + ( c * d ) ) ) ) ; ans . Add ( ( float ) Math . Sqrt ( ( ( a * c ) + ( b * d ) ) * ( ( a * b ) + ( c * d ) ) / ( ( a * d ) + ( b * c ) ) ) ) ; return ans ; } public static void Main ( String [ ] args ) { int A = 10 ; int B = 15 ; int C = 20 ; int D = 25 ; List < float > ans = Diagonals ( A , B , C , D ) ; Console . Write ( " { 0 : F2 } ▁ { 1 : F2 } " , ( ans [ 0 ] ) + .01 , ans [ 1 ] + .01 ) ; } }
Minimum Sum of Euclidean Distances to all given Points | C # program to implement the above approach ; Function to calculate Euclidean distance ; Function to calculate the minimum sum of the euclidean distances to all points ; Calculate the centroid ; Calculate distance of all points ; Driver Code ; Initializing the points
using System ; class GFG { static double find ( double x , double y , int [ , ] p ) { double mind = 0 ; for ( int i = 0 ; i < p . GetLength ( 0 ) ; i ++ ) { double a = p [ i , 0 ] , b = p [ i , 1 ] ; mind += Math . Sqrt ( ( x - a ) * ( x - a ) + ( y - b ) * ( y - b ) ) ; } return mind ; } static double getMinDistSum ( int [ , ] p ) { double x = 0 , y = 0 ; for ( int i = 0 ; i < p . GetLength ( 0 ) ; i ++ ) { x += p [ i , 0 ] ; y += p [ i , 1 ] ; } x = x / p . Length ; y = y / p . Length ; double mind = find ( x , y , p ) ; return mind ; } public static void Main ( String [ ] args ) { int [ , ] vec = { { 0 , 1 } , { 1 , 0 } , { 1 , 2 } , { 2 , 1 } } ; int d = ( int ) getMinDistSum ( vec ) ; Console . Write ( d + " STRNEWLINE " ) ; } }
Coplanarity of Two Lines in 3D Geometry | C # program implement the above approach ; Function to generate determinant ; Return the sum ; Driver Code ; Position vector of first line ; Direction ratios of line to which first line is parallel ; Position vectors of second line ; Direction ratios of line to which second line is parallel ; Determinant to check coplanarity ; If determinant is zero ; Otherwise
using System ; class GFG { static int det ( int [ , ] d ) { int Sum = d [ 0 , 0 ] * ( ( d [ 1 , 1 ] * d [ 2 , 2 ] ) - ( d [ 2 , 1 ] * d [ 1 , 2 ] ) ) ; Sum -= d [ 0 , 1 ] * ( ( d [ 1 , 0 ] * d [ 2 , 2 ] ) - ( d [ 1 , 2 ] * d [ 2 , 0 ] ) ) ; Sum += d [ 0 , 2 ] * ( ( d [ 0 , 1 ] * d [ 1 , 2 ] ) - ( d [ 0 , 2 ] * d [ 1 , 1 ] ) ) ; return Sum ; } public static void Main ( ) { int x1 = - 3 , y1 = 1 , z1 = 5 ; int a1 = - 3 , b1 = 1 , c1 = 5 ; int x2 = - 1 , y2 = 2 , z2 = 5 ; int a2 = - 1 , b2 = 2 , c2 = 5 ; int [ , ] det_list = { { x2 - x1 , y2 - y1 , z2 - z1 } , { a1 , b1 , c1 } , { a2 , b2 , c2 } } ; if ( det ( det_list ) == 0 ) Console . Write ( " Lines ▁ are ▁ coplanar " ) ; else Console . Write ( " Lines ▁ are ▁ non ▁ coplanar " ) ; } }
Distance between Incenter and Circumcenter of a triangle using Inradius and Circumradius | C # program for the above approach ; Function returns the required distance ; Driver code ; Length of Inradius ; Length of Circumradius
using System ; class GFG { static double distance ( int r , int R ) { double d = Math . Sqrt ( Math . Pow ( R , 2 ) - ( 2 * r * R ) ) ; return d ; } public static void Main ( string [ ] args ) { int r = 2 ; int R = 5 ; Console . Write ( Math . Round ( distance ( r , R ) * 100.0 ) / 100.0 ) ; } }
Find N random points within a Circle | C # program for the above approach ; Return a random double between 0 & 1 ; Function to find the N random points on the given circle ; Result vector ; Get Angle in radians ; Get length from center ; Add point to results . ; Return the N points ; Function to display the content of the vector A ; Iterate over A ; Print the N random points stored ; Driver Code ; Given dimensions ; Function call
using System ; using System . Collections . Generic ; class GFG { static readonly double PI = 3.141592653589 ; class pair { public double first , second ; public pair ( double first , double second ) { this . first = first ; this . second = second ; } } static double uniform ( ) { return new Random ( ) . NextDouble ( ) ; } static List < pair > randPoint ( int r , int x , int y , int n ) { List < pair > res = new List < pair > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { double theta = 2 * PI * uniform ( ) ; double len = Math . Sqrt ( uniform ( ) ) * r ; res . Add ( new pair ( x + len * Math . Cos ( theta ) , y + len * Math . Sin ( theta ) ) ) ; } return res ; } static void printList ( List < pair > A ) { foreach ( pair P in A ) { Console . Write ( " ( { 0 : F2 } , ▁ { 1 : F2 } ) STRNEWLINE " , P . first , P . second ) ; } } public static void Main ( String [ ] args ) { int R = 12 ; int X = 3 ; int Y = 3 ; int N = 5 ; printList ( randPoint ( R , X , Y , N ) ) ; } }
Check if an N | C # program for the above approach ; Function to check if the polygon exists or not ; Initialize a variable to store the sum of angles ; Loop through the array and calculate the sum of angles ; Check the condition for an N - side polygon ; Driver code ; Given array arr [ ] ; Function call
using System ; class GFG { static void checkValidPolygon ( int [ ] arr , int N ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += arr [ i ] ; } if ( sum == 180 * ( N - 2 ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } public static void Main ( string [ ] args ) { int N = 3 ; int [ ] arr = { 60 , 60 , 60 } ; checkValidPolygon ( arr , N ) ; } }
Find side of Square which makes minimal area to fit two identical rectangles inside it | C # program of the above approach ; If ' a ' and ' b ' same then double ' a ' or ' b ' and return ( 2 * a ) or ( 2 * b ) ; Check if a != b ; If a > b ; Double the smaller value that is ' b ' and store it to ' newB ' ; Find the difference of ' newB ▁ and ▁ ' a ' ; If ' newB ' < a ; Then add the difference of ' newB ' and ' a ' to the ' b ' to make ' b ' and ' a ' as same ; Return side of the square a or b ; If ' newB ' > a then then add the difference of ' newB ' and ' a ' to the ' a ' to make ' a ' and ' newB ' as same ; Return side of the square a or newB ; If a < b ; Double the smaller value that is ' a ' and store it to ' newA ' ; Find the difference of ' newA ▁ and ▁ ' b ' ; If ' newA ' < b ; Then add the difference of ' newA ' and ' b ' to the ' a ' to make ' a ' and ' b ' as same ; Return side of the square a or b ; If ' newA ' > b then then add the difference of ' newA ' and ' b ' to the ' b ' to make ' b ' and ' newA ' as same ; Return side of the square b or newA ; Driver code ; Size of rectangle
using System ; class GFG { public static int minimalSquareSide ( int a , int b ) { if ( a == b ) { return 2 * a ; } if ( a != b ) { if ( a > b ) { int newB = b + b ; int diff = Math . Abs ( newB - a ) ; if ( newB < a ) { b = newB + diff ; if ( a == b ) return a ; return 0 ; } else { a = a + diff ; if ( a == newB ) return a ; return 0 ; } } else { int newA = a + a ; int diff = Math . Abs ( newA - b ) ; if ( newA < b ) { a = diff + newA ; if ( a == b ) return a ; return 0 ; } else { b = b + diff ; if ( b == newA ) return b ; return 0 ; } } } return 0 ; } public static void Main ( String [ ] args ) { int H , W ; H = 3 ; W = 1 ; Console . WriteLine ( minimalSquareSide ( H , W ) ) ; } }
Find the angle of Rotational Symmetry of an N | C # program to find the angle of Rotational Symmetry of an N - sided regular polygon ; function to find required minimum angle of rotation ; Store the answer in a double variable ; Calculating the angle of rotation and type - casting the integer N to double type ; Driver code
using System ; class GFG { static double minAnglRot ( int N ) { double res ; res = 360 / ( double ) N ; return res ; } public static void Main ( string [ ] args ) { int N = 4 ; Console . Write ( " Angle ▁ of ▁ Rotational ▁ Symmetry : ▁ " + minAnglRot ( N ) ) ; } }
Area of a Triangle from the given lengths of medians | C # program to calculate area of a triangle from the given lengths of medians ; Function to return the area of triangle using medians ; Driver Code ; Function call ; Print the final answer
using System ; class GFG { static double Area_of_Triangle ( int a , int b , int c ) { int s = ( a + b + c ) / 2 ; int x = s * ( s - a ) ; x = x * ( s - b ) ; x = x * ( s - c ) ; double area = ( 4 / ( double ) 3 ) * Math . Sqrt ( x ) ; return area ; } public static void Main ( String [ ] args ) { int a = 9 ; int b = 12 ; int c = 15 ; double ans = Area_of_Triangle ( a , b , c ) ; Console . WriteLine ( ans ) ; } }