标签:10 矩形 const int 面积 矩阵 蓝桥 坐标 include
Description
平面上有两个矩形,它们的边平行于直角坐标系的X轴或Y轴。对于每个矩形,我们给出它的一对相对顶点的坐标,请你编程算出两个矩形的交的面积。Input
输入仅包含两行,每行描述一个矩形。在每行中,给出矩形的一对相对顶点的坐标,每个点的坐标都用两个绝对值不超过10^7的实数表示。
Output
输出仅包含一个实数,为交的面积,保留到小数后两位。Sample Input
1 1 3 3 2 2 4 4
Sample Output
1.00
1 #include <stdio.h> 2 #include <string.h> 3 #include <iostream> 4 #include <string> 5 #include <math.h> 6 #include <algorithm> 7 #include <vector> 8 #include <stack> 9 #include <queue> 10 #include <set> 11 #include <map> 12 #include <sstream> 13 const int INF=0x3f3f3f3f; 14 typedef long long LL; 15 const int mod=1e9+7; 16 const int maxn=1e5+10; 17 using namespace std; 18 19 struct node 20 { 21 double x; 22 double y; 23 int num; 24 }PT[5]; 25 26 int main() 27 { 28 #ifdef DEBUG 29 freopen("sample.txt","r",stdin); 30 #endif 31 // ios_base::sync_with_stdio(false); 32 // cin.tie(NULL); 33 34 for(int i=1;i<=4;i++) 35 scanf("%lf %lf",&PT[i].x,&PT[i].y); 36 double ans=0; 37 double x1=max(min(PT[1].x,PT[2].x),min(PT[3].x,PT[4].x)); 38 double x2=min(max(PT[1].x,PT[2].x),max(PT[3].x,PT[4].x)); 39 double y1=min(max(PT[1].y,PT[2].y),max(PT[3].y,PT[4].y)); 40 double y2=max(min(PT[1].y,PT[2].y),min(PT[3].y,PT[4].y)); 41 if(x1>=x2||y1<=y2) ans=0; 42 else ans=((x2-x1)*(y1-y2)); 43 printf("%.2f\n",ans); 44 45 return 0; 46 }
-
标签:10,矩形,const,int,面积,矩阵,蓝桥,坐标,include 来源: https://www.cnblogs.com/jiamian/p/12233054.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。