蓝桥杯--矩阵面积交

http://47.104.209.207/problem/old1060

计算出相交矩阵的左下和右上两个顶点。

 1 #include<cmath>
 2 #include<iostream>
 3 #include<queue>
 4 #include<vector>
 5 #include<algorithm>
 6 using namespace std;
 7 int main(){
 8     double x1,y1,x2,y2;
 9     double x3,y3,x4,y4;
10     cin>>x1>>y1>>x2>>y2;
11     cin>>x3>>y3>>x4>>y4;
12     double m1=max(min(x1,x2),min(x3,x4));
13     double n1=max(min(y1,y2),min(y3,y4));
14     double m2=min(max(x1,x2),max(x3,x4));
15     double n2=min(max(y1,y2),max(y3,y4));
16     if(m2>m1&&n2>n1){
17         printf("%.2f",(double)(m2-m1)*(n2-n1));
18     }else{
19         printf("%.2f",0);
20     }
21     return 0;
22 }

 

上一篇:求三角形面积(已知3点坐标)


下一篇:扩展欧几里得算法求逆元python代码实现(含递归与非递归算法)