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