// C# program to count number
// of triangles that can be formed
// with given points in 2D
using System;
class GFG{
// Returns determinant value
// of three points in 2D
static int det(int x1, int y1, int x2, int y2, int x3, int y3)
{
return (x1 * (y2 - y3) - y1 *
(x2 - x3) + 1 * (x2 *
y3 - y2 * x3));
}
// Returns count of possible
// triangles with given array
// of points in 2D.
static int countPoints(int[,] Point, int n)
{
int result = 0; // Initialize result
// Consider all triplets of
// points given in inputs
// Increment the result when
// determinant of a triplet is not 0.
for(int i = 0; i < n; i++)
for(int j = i + 1; j < n; j++)
for(int k = j + 1; k < n; k++)
if(det(Point[i,0], Point[i,1], Point[j,0], Point[j,1],Point[k,0], Point[k,1])>=0)
result = result + 1;
return result;
}
// Driver code
public static void Main()
{
int[,] Point = new int[,] { { 0, 0 }, { 1, 1 }, { 2, 0 }, { 2, 2 } };
int n = Point.Length/Point.Rank;
Console.WriteLine(countPoints(Point, n));
}
}
// This code is contributed by mits