View Code of Problem 106

#include<bits/stdc++.h>
using namespace std;
#define max 50
int main(){
	int x1,x2,y1,y2; 
	double l,R,mm,gg,S,r;
	while(scanf("%d%d%d%d%lf",&x1,&y1,&x2,&y2,&r)!=EOF){
		l = sqrt(abs(x1-x2)*abs(x1-x2) + abs(y1-y2)*abs(y1-y2));
		if(x1==x2 && y1==y2)cout<<"重合"<<endl;
		else if(2*r == l)cout<<"相切"<<endl;
		else if(l > 2*r) cout<<"相离"<<endl;
		else{
			cout<<"相交"; 
			mm=acos(l*0.5/r);
			 gg=mm*r*r;
			 S=gg-0.5*r*r*sin(mm);
			 S=S*2;
			printf(" %.2f\n",S);				
		} 	 
	}
	
	
	
	
	return 0;
}

Double click to view unformatted code.


Back to problem 106