View Code of Problem 106

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

Double click to view unformatted code.


Back to problem 106