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