View Code of Problem 106

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.14159
int main(){
	double x1,y1,x2,y2,r,d;
	while(scanf("%lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&r)!=EOF){
		d=sqrt(pow((x1-x2),2)+pow((y1-y2),2));
		if(x1==x2&&y1==y2) printf("重合\n");
		else if(d>2*r) printf("相离\n");
		else if(d==2*r) printf("相切\n");
		else if(d<2*r&&d>0){
			double a,s,i,j;
			a=acos(d/(2.0*r));
			s=2.0*(r*r*a-0.5*r*r*sin(2*a));
			printf("相交 %.2lf\n",s); 
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 106