NOTAMYSE @ 2017-08-27 16:05:32
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
double j = 0.00000,
int i=0,
int k;
cin >> k;
do
{
i++;
j = j+(1.0 / i);
} while (j <= k);
cout<<i;
return 0;
}
by 宇智波佐小助 @ 2017-08-27 16:41:20
先把我的代码贴给你
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
double d=0;
int k,n=0;
scanf("%d",&k);
while(d<=k){
n++;
d+=1.0/n*1.0;
}
cout<<n;
return 0;
}
by 宇智波佐小助 @ 2017-08-27 16:47:31
问题应该是把分号打成了逗号
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
double j = 0.00000;//可以直接写j=0;
int i=0;//注意分号;
int k;
cin >> k;
do
{
i++;
j = j+1.0/i*1.0;
} while (j <= k);
cout<<i;
return 0;
}
//这样就好了
by NOTAMYSE @ 2017-08-27 16:50:11
谢谢
by NOTAMYSE @ 2017-08-27 16:50:54
居然有低级错误【摊手】