/*Basic Practice Rectangle Area intersection Problem The description plane has two rectangles, their edges parallel to the x-axis or y-axis of the Cartesian coordinate system. For each rectangle, we give the coordinates of its pair of relative vertices, so you can programmatically figure out the intersection area of two rectangles. Input format input contains only two lines, and each line describes a rectangle. In each row, the coordinates of a pair of relative vertices of a rectangle are given, and the coordinates of each point are represented by a real number of two absolute values that do not exceed 10^7. The output format output contains only a real number, which is the intersection of the area, reserved to a decimal after two bits. Example input 1 1 3 3 2 2 4 4 sample output 1.00*/ //the intersection area of the rectangle. #include <stdio.h>#defineMax (x, y) (() > (y)? ( x):(y))#defineMin (x, y) ((×) < (y)? ( x):(y))intMain () {DoubleX1,y1,x2,y2;//Rectangle 1 DoubleX3,y3,x4,y4;//Rectangle 2 DoubleM1,N1;//the coordinates of the upper-left corner of the intersection. DoubleM2,N2;//coordinates of the lower-right corner of the intersection.scanf"%LF%LF%LF%LF",&x1,&y1,&x2,&y2); scanf ("%LF%LF%LF%LF",&x3,&y3,&x4,&y4); M1=Max (min (x1,x2), Min (x3,x4)); N1=Max (min (y1,y2), Min (y3,y4)); M2=min (max (x1,x2), Max (x3,x4)); N2=min (max (y1,y2), Max (Y3,Y4)); if(M2>m1 && n2>N1) printf ("%.2f\n", (M2-M1) * (N2-N1)); Elseprintf ("0.00\n"); return 0;}
Blue Bridge Cup _ basic practice "rectangular area---26"