程序代码:
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
int main()
{
int a;
double b = 0;
int c = 1;
for (a = 1; a <= 100; a++)
{
b = b+(1.0*c) / a;
c = -c;
}
printf("%.3f", b);
system("pause");
return 0;
}
程序代码:
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
int main()
{
int a;
double b = 0;
int c = 1;
for (a = 1; a <= 100; a++)
{
b = b+(1.0*c) / a;
c = -c;
}
printf("%.3f", b);
system("pause");
return 0;
}