You are on page 1of 2

// You could use this sample code to test your C functions

// Please make appropriate changes to use this for C++.


// Following main function contains 3 representative test cases
int main()
{
// Testcase 1
{
int points[][2] = {{3,1},{2,3},{1,2},{3,2},{2,4},{4,3},{4,4},{5,
2}};
int noofcoord = 8;
struct convexhull* res = getConvex(points, noofcoord);
printf("\nOutput 1 : ");
if(res != NULL)
{
printf("{ ");
for(int i=0;i<res->size;i++)
{
printf ("{%d, %d} ",res->pts[i][0], res->pts[i][
1]);
}
printf("}");
}
else printf("NULL");
}
// Testcase 2
{
int points[][2] = {{2,1},{2,2},{1,3},{3,3}};
int noofcoord = 4;
struct convexhull* res = getConvex(points, noofcoord);
printf("\nOutput 2 : ");
if(res != NULL)
{
printf("{ ");
for(int i=0;i<res->size;i++)
{
printf ("{%d, %d} ",res->pts[i][0], res->pts[i][
1]);
}
printf("}");
}
else printf("NULL");
}
// Testcase 3
{
int points[][2] = {{2,1},{2,2}};
int noofcoord = 2;
struct convexhull* res = getConvex(points, noofcoord);
printf("\nOutput 3 : ");
if(res != NULL)
{
printf("{ ");
for(int i=0;i<res->size;i++)
{

printf ("{%d, %d} ",res->pts[i][0], res->pts[i][


1]);
}
printf("}");
}
else printf("NULL");
}
}

You might also like