// Cyclotomic.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <IOSTREAM>
#include <CSTDIO>
#include <CSTDLIB>
#include <CMATH>
using namespace std;
void Cyclotomic(int n)
{
int i, s;
double k, len;
i = 0;
k = 3.0;
len = 1.0;
s= 6;
while(i <= n)
{
printf("第%2d次切割,为正%5d边形,PI=%24f\n", i, s, k*sqrt(len));
s *= 2;
len = 2 - sqrt(4 - len);
i++;
k *= 2.0;
}
}
int main(int argc, char* argv[])
{
int n;
printf("输入切割圆次数: !\n");
scanf("%d", &n);
Cyclotomic(n);
return 0;
}
PI算法
最新推荐文章于 2023-06-20 16:35:35 发布