,各位大佬,请问为什么会错误

P1035 [NOIP2002 普及组] 级数求和

Kdlyh @ 2018-02-18 11:07:24

include<iostream>

using namespace std; int main() { int n,k=1;double s=0.0000; cin>>n; do{ s++; k+=1/s; }while(k<=n); cout<<k; return 0; }


by dying @ 2018-02-28 16:50:42

while(k<n)


by Kdlyh @ 2023-11-17 17:40:11

@dying 谢谢指点!(有点迟)


|