#include <stdio.h> #include <math.h> #define pai=3.141592; int main(){ double x1,y1,x2,y2,r; double distance; while(scanf("%lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&r)!=EOF){ distance = sqrt(pow((x2-x1),2)+pow((y2-y1),2)); if(distance==0){ printf("重合\n"); }else if(distance==2*r){ printf("相切\n"); }else if(distance>2*r){ printf("相离\n"); }else if(distance<2*r){ printf("相交 "); double x=acos(distance/(2*r)); double s=r*r*x/2-distance/2*r*sin(x)/2; printf("%.2lf\n",4*s); } } } |
Double click to view unformatted code.