例
#include <bits/stdc++.h> using namespace std; //寻找外接圆的半径 float findRadiusOfcircumcircle(float n, float a) { if (n < 0 || a < 0) return -1; float radius = a / sqrt(2 - (2 * cos(360 / n))); return radius; } int main() { float n = 5, a = 6; cout << findRadiusOfcircumcircle(n, a) << endl; return 0; }
输出结果
3.02487