求多项式的和

在这里插入图片描述

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
    
    
	int n,l[1001];
	while(scanf("%d",&n) !=EOF){
    
    
		for(int i=0;i<n;i++){
    
    
			cin>>l[i];
			double s=0;
			for(int j=1;j<=l[i];j++){
    
    
				s+=pow(-1,j+1)/j; 
			}
			printf("%.2lf\n",s);
		}
	}
	return 0;
}

还是比较简单的内容,每天练一道
加油!!
少年心事当拿云!
–李贺

猜你喜欢

转载自blog.csdn.net/interestingddd/article/details/113751981
今日推荐