您的位置:首页 > 其它

Tsinsen-A1042-矩阵面积交

2017-01-08 11:52 225 查看
#include <cstdio>
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
double x1, x2, x3, x4, y1, y2, y3, y4;
cin >> x1 >> y1 >> x2 >> y2;
cin >> x3 >> y3 >> x4 >> y4;

if (x1 > x2) swap(x1, x2);//保证下标1保存左下角的点
if (y1 > y2) swap(y1, y2);
if (x3 > x4) swap(x3, x4);
if (y3 > y4) swap(y3, y4);

double x = min(x2, x4) - max(x1, x3);
x = x < 0 ? 0.0 : x;
double y = min(y2, y4) - max(y1, y3);
y = y < 0 ? 0.0 : y;
//精度两位
cout.precision(2);
cout << fixed << x*y << endl;
}


2017.1.8
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  OJ