/* 1-2/3+3/5-4/7+5/9-6/11+.......的前n项之和*/
int main(int argc, char *argv[])
{
int num_n = 1;
int i = 0;
double result = 0.0;
printf("please input a Integer:");
//scanf("%d", &num_n);
num_n = 3;
for(i=0; i
result += ((i%2)?(-(double)(i+1)/(2*i+1)):((double)(i+1)/(2*i+1)));
}
printf("result = %f.\n", result);
return 0;
}
#include
#include
using namespace std;
int main()
{
int n = 0;
cin>>n;
double i = 1,s= 0;
while(i
s = s -(pow(-1,i)) * i / (2*i - 1) ;
i++;
}
cout<}
int i,k=-1;
double s=0,a=0;
for(i=1;i<=n;i++)
{ a=-(double)(2*i-1);
s+=(double)i/a; }