#include<stdio.h> #include<math.h> int main() { double x1,y1,x2,y2,r; double dist; while(~scanf("%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&r)){ dist=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); if(dist==0)printf("重合\n"); else if(dist==2*r)printf("相切\n"); else if(dist>2*r)printf("相离\n"); else { printf("相交 "); double s,angle; angle=2.0*acos(dist/2.0/r); s=r*r*angle/2*2-r*sin(angle/2)*dist;//两个扇形减去菱形 printf("%.2lf\n",s); } } return 0; } |
Double click to view unformatted code.