2056.cpp

来自「杭电 acm部分代码 有兴趣的可以下载 谢谢」· C++ 代码 · 共 31 行

CPP
31
字号
#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>
using namespace std;
double x[4], y[4];
double length(double a, double b, double c, double d)
{
	if(a > b)
		swap(a, b);
	if(c > d)
		swap(c, d);
	if(a > c)
	{
		swap(a, c);
		swap(b, d);
	}
	if(b > d)
		return d - c;
	else if(b < c)
		return 0;
	else
		return b - c; 
}

int main()
{
	while(cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3])
		printf("%.2lf\n", length(x[0], x[1], x[2], x[3]) * length(y[0], y[1], y[2], y[3]));
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?