Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.