欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

习题2-4 子序列的和(subsequence)

程序员文章站 2024-03-18 23:30:10
...
#include <stdio.h>

int main()
{
	int n,m;
	int kase = 0;
	
	while(scanf("%d%d",&n,&m) == 2 && ( n || m ))
	{
		double num;
		double sum = 0;
		for(int i=n;i<=m;i++){
			num = (double) 1/i/i;
			sum = num + sum;
		}
		printf("Case %d: %.5f\n",++kase,sum);
	}
	
	return 0;
}