View Code of Problem 106

#include<bits/stdc++.h>
using namespace std;
int main()
{
    double x1,y1,x2,y2,r;
    while(cin>>x1>>y1>>x2>>y2>>r)
    {
    	if(x1==x2&&y1==y2)
    	cout<<"重合"<<endl;
    	else
    	{
    		double d=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
			if(d==2*r)
			cout<<"相切"<<endl;
			else if(d>2*r)
			cout<<"相离"<<endl;
			else
			{
				double a=acos(d/2/r);
				double s=2*(r*r*a-d/2*r*sin(a));
				printf("相交 %.2f\n", s);
			}
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 106