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){
		double d = sqrt(pow(y2-y1,2)+pow(x2-x1,2));
		if(d == 0) cout<<"重合"<<endl;
		else if(d == 2*r) cout<<"相切"<<endl;
		else if(d > 2*r) cout<<"相离"<<endl;
		else{
			double ang1=acos((r*r+d*d-r*r)/(2*r*d));
			double ang2=acos((r*r+d*d-r*r)/(2*r*d));
			printf("相交 %.2lf\n",ang1*r*r + ang2*r*r - r*d*sin(ang1));
		} 
	} 
}

Double click to view unformatted code.


Back to problem 106