View Code of Problem 106

#include<string>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<algorithm>
using namespace std;
int main()
{
	double x1, y1, x2, y2, r;
	while (cin >> x1 >> y1 >> x2 >> y2 >> r)
	{
		double d = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
		if (d > 2 * r)
			cout << "相离" << endl;
		else if (d == 2 * r)
			cout << "相切" << endl;
		else if (d == 0)
			cout << "重合" << endl;
		else
		{
			double sita = 2 * acos(d / (2 * r));
			double s = r * r*sita - r * r*sin(sita);
			cout <<fixed<<setprecision(2)<< s << endl;
		}
	}
	
}

Double click to view unformatted code.


Back to problem 106