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