http://acm.hit.edu.cn/hoj/problem/view?id=1331
#include <stdio.h>
#include <math.h>
double f(int n);
int main()
{
int n;
printf("# Cards Overhang\n");
while (scanf("%d", &n) != EOF)
{
printf("%5d %.3lf\n", n, f(n));
}
return 0;
}
double f(int n)
{
int i;
double s=0;
for(i = 2; i <= 2*n; i += 2)
{
s += 1.0/i;
}
return s;
}
本文介绍了一个用于计算卡片悬挂高度的算法实现过程,包括输入卡片数量并输出相应的悬挂高度,采用数学公式进行计算。
2849

被折叠的 条评论
为什么被折叠?



