给出三点求外接圆圆心、半径
double a = ((y2 - y1) * (y3 * y3 - y1 * y1 + x3 * x3 - x1 * x1) - (y3 - y1) * (y2 * y2 - y1 * y1 + x2 * x2 - x1 * x1)) / (2.0 * ((x3 - x1) * (y2 - y1) - (x2 - x1) * (y3 - y1)));
double b = ((x2 - x1) * (x3 * x3 - x1 * x1 + y3 * y3 - y1 * y1) - (x3 - x1) * (x2 * x2 - x1 * x1 + y2 * y2 - y1 * y1)) / (2.0 * ((y3 - y1) * (x2 - x1) - (y2 - y1) * (x3 - x1)));
double r2 = (x1 - a) * (x1 - a) + (y1 - b) * (y1 - b);
质数
bool isPrime(int n) { //返回1表示判断为质数,0为非质数
float n_sqrt;
if (n == 2 || n == 3) return true;
if (n % 6 != 1 && n % 6 != 5) return false;
n_sqrt = floor(sqrt((float)n));
for (int i = 5; i <= n_sqrt; i += 6) {
if (n % (i) == 0 | n % (i + 2) == 0) return false;
}
return true;
}
来源:CSDN
作者:nirvana · rebirth
链接:https://blog.csdn.net/Q_1849805767/article/details/104042571