#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
typedef struct NODE{
int n;
int power;
struct NODE* pre;
struct NODE* next;
}NODE;
void PiCreateAndInitial(NODE* head,int m) {
//创建双向循环链表,并且初始化链表
int tempx=m;
NODE* temp = head;
for (;m>=0;m--){
NODE* p = (NODE*)malloc(sizeof(NODE));
if (p) {
if(m==tempx){
p->n=1;
}else{
p->n=0;
}
p->power=m-tempx;
temp->next = p;
p->pre=temp;
temp = p;
}
}
temp->next=head;
head->pre=temp;
}
void PiOutput(NODE* head,int m) {
//链表的遍历
char s[520]={0};
char *sp=s;
NODE* p = head->next;
while ((m--)>=0) {
*sp=(p->n)+48;
sp=sp+1;
if((p->power)==0){
*sp='.';
sp
西工大NOJ数据结构实验——1.2高精度计算PI值
于 2022-03-13 11:32:35 首次发布