0
点赞
收藏
分享

微信扫一扫

HDOJ  1012    u Calculate e

张宏涛心理 2022-08-23 阅读 112


题目:​​http://acm.hdu.edu.cn/showproblem.php?pid=1012​​

注意一下中间数据的保存,和最后结果的输出...

#include <stdio.h>
int main()
{
printf("n e\n");
printf("- -----------\n");
printf("0 1\n");
printf("1 2\n");
printf("2 2.5\n");
int a;
double sum=2.5,fe=0.5;
for(int i=3;i<=9;i++)
{
fe=fe*(1.0/i);
sum+=fe;
printf("%d %.9lf\n",i,sum);
}
return 0;
}

举报

相关推荐

0 条评论