View Code of Problem 106

#include<bits/stdc++.h>
using namespace std;
int main(){
	double x,y,z,w,r,l,a,b;
	while(cin>>x>>y>>z>>w>>r){
		l=sqrt((z-x)*(z-x)+(w-y)*(w-y));
		if(l==0)cout<<"重合";
		else if(l==2*r)cout<<"相切";
		else if(l>2*r)cout<<"相离";
		else if(l<2*r){
			a=acos(l/2/r)*2;
			b=r*r*a-r*r*sin(a);
			printf("相交 %.2lf",b);
		}
		cout<<endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 106