View Code of Problem 106

#include <stdio.h>
#include <string.h>
#include <math.h>
    int main()
    {
        double x1,x2,y1,y2,r;
        while(scanf("%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&r) != EOF)
        {
            double s,a,z;
            s = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
            if(s == 2*r)
                printf("相切\n");
            else if((x1 == x2) && (y1 == y2))
                printf("重合\n");
            else if(s > 2*r)
                printf("相离\n");
            else
            {
                printf("相交 ");
                z = acos(s / (2*r));
                a = 2 * r * r * z - s * r * sin(z);
                printf("%.2lf\n",a);
            }
        }
    }

Double click to view unformatted code.


Back to problem 106