On 8/4/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]
> wrote:
To define a rectangle only 2 diagonal coordiantes((left,top) and
(right,bottom) are sufficient.
void main(){
int top1,left1,bottom1,right1;//rect1
int top2,left2,bottom2,right2;//rect2
int top3,left3,bottom3,right3;//intersecting rect
printf("first rect :");
scanf("%d %d %d %d\n",&top1,&left1,&bottom1,&right1);
printf("second rect :");
scanf("%d %d %d %d\n",&top2,&left2,&bottom2,&right2);
int Area;
if(left2 > right1)
Area = 0;
else if(left2 > left1)
left3 = left2;
else
left3 = left1;
if(top2 < bottom1)
Area = 0;
else if(top2 < top1)
top3 = top2;
else
top3 = top1;
if(right2 < left1)
Area = 0;
else if(right2 < right1)
right3 = right2;
else
right3 = right1;
if(bottom2 > top1)
Area = 0;
else if(bottom2 > bottom1)
bottom3 = bottom2;
else
bottom3 = bottom1;
if(Area != 0){
Area = (top3-bottom3)*(right3-left3);
printf("intersecting rect :");
printf("%d %d %d %d %d\n",top3,left3,bottom3,right3,Area);}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---
- [algogeeks] Intersection of 2 rectangles Ashwin Murthy
- [algogeeks] Re: Intersection of 2 rectangle... Mukul Gandhi
- [algogeeks] Re: Intersection of 2 recta... Ashwin Murthy
- [algogeeks] Re: Intersection of 2 r... [EMAIL PROTECTED]
- [algogeeks] Re: Intersection of... Balasubramaniam Mariappan
- [algogeeks] Re: Intersection of... Vishal
- [algogeeks] Re: Intersection of 2 rectangle... Paul Hsieh
- [algogeeks] Re: Intersection of 2 recta... Guillermo Garcia
- [algogeeks] Re: Intersection of 2 r... Paul Hsieh