超简单控制精度
查看原帖
超简单控制精度
295671
yegetables楼主2020/12/6 00:02

不多说了,看代码

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int n;
    scanf("%d", &n);
    double x1, x2, x3;
    x1 = pow((1.0000000000000 + pow(5.0000000, 0.5)) / 2.0000000, 1.0000000 * n);
    x2 = pow((1.0000000000000 - pow(5.0000000, 0.5)) / 2.0000000, n * 1.0000000);
    x3 = (x1 - x2) * 1.000000 / (pow(5.000000, 0.5));
    printf("%.2f", x3);
}
2020/12/6 00:02
加载中...