//求数列1,1/2,1/3...所有大于0.00001的数相加
#include<iostream>
using namespace std;
int main()
{
float a = 1.0, b = 0.0;
float n = 1;
while (a > 0.00001)
{
a = 1 / n;
n++;
b = b + a;
}
cout << "b为" << b;
system("pause");
}
//求数列1,1/2,1/3...所有大于0.00001的数相加
#include<iostream>
using namespace std;
int main()
{
float a = 1.0, b = 0.0;
float n = 1;
while (a > 0.00001)
{
a = 1 / n;
n++;
b = b + a;
}
cout << "b为" << b;
system("pause");
}