View Code of Problem 106

#include <iostream>
#include <cstdio>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
    double x1,x2,y1,y2,r,d,k,s;
    while(cin>>x1>>y1>>x2>>y2>>r){
        d=sqrt(pow((x1-x2),2)+pow((y1-y2),2));
        if(x1==x2&&y1==y2)
            cout<<"重合"<<endl;
        else if(d==2*r)
            cout<<"相切"<<endl;
        else if(d>2*r)
            cout<<"相离"<<endl;
        else if(d<2*r){
            k=acos(d/2.0/r);
            s=r*k*r-(r*d*sin(k))/2.0;
            cout<<"相交"<<" "<<fixed<<setprecision(2)<<s*2<<endl;
        }
    }
    return 0;
}


Double click to view unformatted code.


Back to problem 106