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