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