View Code of Problem 106

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

Double click to view unformatted code.


Back to problem 106