#include<bits/stdc++.h> using namespace std; int main() { float x1, y1, x2, y2, r; while (cin >> x1 >> y1 >> x2 >> y2 >> r) { if (pow((x2 - x1), 2) + pow((y2 - y1), 2) ==0) { cout << "重合" << endl; }else if(pow((x2 - x1), 2) + pow((y2 - y1), 2) >4* pow(r, 2)) { cout << "相离" << endl; } else if (pow((x2 - x1), 2) + pow((y2 - y1), 2) == 4*pow(r, 2)) { cout << "相切" << endl; } else { cout << "相交 "; double a; float d = sqrt(pow(fabs(x2 - x1), 2) + pow(fabs(y2 - y1), 2)); double o = acos(0.5*d / r); a = (0.5*o*r*r) * 2; a = a - sqrt(r*r - d * d / 4)*d / 2; a = a * 2; cout << setiosflags(ios::fixed) << setprecision(2) << a << endl; } } return 0; } |
Double click to view unformatted code.