Blue Bridge Cup _ basic practice "rectangular area---26"

Source: Internet
Author: User

/*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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.