杭电ACM_2011

杭电ACM_2011_第1张图片

2011 c
[code]
#include 
int main(){
     
	int m,n,i,j,tmp;
	double num;
	while(scanf("%d",&m)!=EOF){
     
		for(i=0;i<m;i++){
     
			scanf("%d",&n);
			num=0;tmp=-1;
			for(j=1;j<=n;j++)
			{
     
				tmp=-tmp;
				num+=tmp*(1.0/j);
				
			}
			printf("%.2lf\n",num);
			
		}
	}
	return 0;
} 
[/code]

你可能感兴趣的:(C语言基础,算法)