Match Shapes - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Match Shapes

rkgamateurrkgamateur Posts: 17Member
In this problem, you are given a set of points. By combining these points in given order by lines you get a shape. You need to check whether it matches with S shape which could be rotated by 90, 180, 270 degree.

Depending on the type of shape it matches you need to return that number. For example if it matches with shape 1 of the diagram return 1. If it doesn't matches any return 0.

The prototype of the function is:

int matchshapes(struct point p[],int size); where p is given array of points, size represents array size

Constraints

A given set of points that makes S shape has its all lines that are parallel either x or y axis.
Example 1

Input
p[0] = (0,0)
p[1] = (1,0)
p[2] = (1,1)
p[3] = (1,2)
p[4] = (0,2)
p[5] = (0,3)
p[6] = (1,3)
p[7] = (2,3)
Output
Function "matchshapes" returns 2
Explanation : The given set of points represents 2nd diagram shown in the figure Click Here i.e. function matchshapes will return 2.

Example 2

Input
p[0] = (0,0)
p[1] = (1,0)
p[2] = (1,1)
p[3] = (0,1)
p[4] = (0,2)
p[5] = (0,3)
p[6] = (1,3)
p[7] = (2,4)
Output
Function "matchshapes" returns 0

Someone please help me out in this. u can provide the code or any ideas on this.
Sign In or Register to comment.