HDU 1012 u Calculate e
程序员文章站
2022-07-15 08:51:05
...
传送门:HDU 1012
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int multiply[15];
double summul[15];
multiply[0] = 1;
summul[0] = 1;
for(int i=1;i<10;i++)
{
multiply[i] = multiply[i-1]*i;
summul[i] = summul[i-1]+1/(double)multiply[i];
}
printf("n e\n");
printf("- -----------\n");
printf("0 1\n");
printf("1 2\n");
printf("2 2.5\n");
for(int i = 3;i<10;i++)
printf("%d %.9lf\n",i,summul[i]);
return 0;
}
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int multiply[15];
double summul[15];
multiply[0] = 1;
summul[0] = 1;
for(int i=1;i<10;i++)
{
multiply[i] = multiply[i-1]*i;
summul[i] = summul[i-1]+1/(double)multiply[i];
}
printf("n e\n");
printf("- -----------\n");
printf("0 1\n");
printf("1 2\n");
printf("2 2.5\n");
for(int i = 3;i<10;i++)
printf("%d %.9lf\n",i,summul[i]);
return 0;
}
上一篇: B树第三节学习(插入与删除的思路与理论)
下一篇: B树第二节学习(理论与思想及思路)