View Code of Problem 106

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

Double click to view unformatted code.


Back to problem 106