creed_ @ 2017-07-12 17:25:31
#include<iostream>
using namespace std;
int main()
{
float i=0,s=0;
int k;
cin>>k;
while (s<=k)
{
i++;
s+=1/i;
}
cout<<i;
}
by lrj124 @ 2017-07-12 18:15:57
也许这样就对了
float i=0,s=1;
by lrj124 @ 2017-07-12 18:16:27
float i=0,s=1;
by lrj124 @ 2017-07-12 18:21:45
@ creed_
哦,i也要置为1,还有,float不行,要用double。
应为:
double i=1,s=1;