View Code of Problem 106

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

Double click to view unformatted code.


Back to problem 106