#include<iostream> #include<math.h> using namespace std; void YuanXin(double x1,double y1,double x2,double y2,double R,double &x,double &y) { double c1 = (x2*x2 - x1*x1 + y2*y2 - y1*y1) / (2 *(x2 - x1)); double c2 = (y2 - y1) / (x2 - x1); double A = (c2*c2 + 1); double B = (2 * x1*c2 - 2 * c1*c2 - 2 * y1); double C = x1*x1 - 2 * x1*c1 + c1*c1 + y1*y1 - R*R; cout << B*B - 4 * A*C << endl; y = (-B + sqrt(B*B - 4 * A*C)) / (2 * A); x = c1 - c2 * y; cout << "x=" << x << "y=" << y << endl; } int main() { double a=0, b=0; YuanXin(1, -6, 6, -1, 5, a, b); cout << "a=" << a << "b=" << b << endl; return 0; }