I have a problem with me.I'm unable to understand it.So I want from you the meaning and explanation of that problem below.I don't want program from you.
----------------------
A rectangle with sides parallel to the X- and Y-axes is specified by four real numbers a, b, c, and d. Assume that a <= c and b <= d. The four corners of the rectangle are (a,b) [bottom left], (c,b) [bottom right], (a,d) [top left], and (c,d) [top right].

Read the values a1, b1, c1, and d1 from the user for a rectangle R1. Subsequently, read the values a2, b2, c2, and d2 for another rectangle R2. Your task is to determine whether the two rectangles R1 and R2 intersect.

To solve this problem, it suffices to check whether both the following conditions are satisfied:

* The interval [a1, c1] has an overlap with the interval [a2, c2].
* The interval [b1, d1] has an overlap with the interval [b2, d2].

Two real intervals I = [s,t] and J = [u,v] operlap if and only if I starts before J ends and J starts before I ends, that is, if and only if s <= v and u <= t.

Report the output of your program for the following four runs.

a1, b1, c1, d1 a2, b2, c2, d2

1, 2, 3, 4 2, 3, 4, 5

1, 2, 3, 4 3, 4, 5, 6

1, 2, 3, 4 4, 5, 6, 7

1, 2, 3, 4 1.5, 5, 2.5, 6
---------------------------------------------

Recommended Answers

All 3 Replies

By convention, x and y denote a range of values in the horizontal and vertical direction respectively, on a plane. Taken together, they give the exact location of any point on that plane. Common name - coordinates or Cartesian coordinates.

So draw yourself a graph and label some x and y points on it. Now draw some rectanges - have some overlap (intersect), and others not overlap, and look at their coordinate values for x and y.

Look at the points where they intersect, and look at the points where they are not intersecting.

Hmmmmmmm! Something interesting there!! ;)

Draw yourself the graph of these x and y values, and the rectangles and points. Seeing it on paper is a big help.

u have to use graphics.h in header files, check whether the coordinates are correct or not.

#include<stdio.h>
#include<conio.h>
main(){
       int a,b,c,d,a1,b1,c1,d1;
       
       printf("enter the values of a :\n");
       scanf("%d",&a);
       printf("enter the value of b :\n");
       scanf("%d",&b);
       printf("enter the values of c :\n");
       scanf("%d",&c);
       printf("enter the value of d :\n");
       scanf("%d",&d);
       printf("enter the values of a1 :\n");
       scanf("%d",&a1);
       printf("enter the value of b1 :\n");
       scanf("%d",&b1);
       printf("enter the values of c1 :\n");
       scanf("%d",&c1);
       printf("enter the value of d1 :\n");
       scanf("%d",&d1);
      
                 if(((a<a1)&(a1<c)) && ((b<b1)&(b1<d))){
                             printf("\ntwo rectangles are overlap\n");
                             }
                             else{
                                  printf("not overlap");
                                  }
                                  getch();
                                  }

POSTED BY : HIMAM SK IT HRT APIIIT,NUZVID, EMAIL: <snip>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.