i正义的伙伴i @ 2019-07-19 19:02:58
using namespace std; int K; float S=0.0,i=1.0; int main() { cin>>K; while(S<=K) { S=S+(1/i); i=i+1; } cout<<i-1; return 0; }
by 1saunoya @ 2019-07-19 19:05:37
建议double
by zimindaada @ 2019-07-19 19:45:39
#include<iostream>
using namespace std;
int K;
float S=0.0,i=1.0;
int main() {
cin>>K;
while(S<=K) {
S=S+(1/i);
i=i+1;
}
cout<<i-1;
return 0;
}
by zimindaada @ 2019-07-19 19:45:49
希望更丰富的展现?使用Markdown
by i正义的伙伴i @ 2019-07-20 17:40:54
@清风ღ AC了,多谢