#include<iostream> #include<string> #include<cmath> #include<iomanip> #include<vector> #include<cstring> #include<algorithm> using namespace std; int main() { double x1, x2, y1, y2, r; while (cin >> x1 >> y1 >> x2 >> y2 >> r) { double 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 (x1 == x2 && y1 == y2) { cout << "重合" << endl; } else if (d < 2 * r) { double co = d / 2.0 / r; double jiao =2*acos(co); double si = sin(jiao); double s = pow(r, 2)*(jiao - si); cout << "相交 " << fixed << setprecision(2) << s << endl; } } } |
Double click to view unformatted code.