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